• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (c) 2015-2018 Khronos Group. This work is licensed under a
2// Creative Commons Attribution 4.0 International License; see
3// http://creativecommons.org/licenses/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[[extensions-rules]]
42== General Rules/Guidelines
43
44Some general rules to simplify the specific rules below:
45
46  * API versions, extensions and layers must each have a globally unique
47    name.
48  * All commands and tokens must have a globally unique name.
49  * API versions and extensions can expose new commands, types, and/or
50    tokens, but layers must not.
51  ** However, layers can expose their own extensions, which in turn are
52     allowed to expose new commands and tokens.
53  * All extensions must be registered with Khronos.
54  * Extensions in general are strictly additive and backwards-compatible
55    with each other and with the core API.
56    However, as described in more detail the Fundamentals chapter of the
57    <<vulkan-spec,Vulkan API Specification>>, explicit incompatibilities may
58    exist, and must be documented.
59
60
61[[extensions-naming-conventions]]
62== Version, Extension, and Layer Naming Conventions
63
64Versions, extensions and layers have formal _names_.
65These names are used in a variety of places:
66
67  * When specifying extensions and layers to enable in the API.
68  * As a preprocessor symbol in the `vulkan_core.h` header file indicating
69    that an extension interface is defined at compile time.
70  * To control building the Vulkan Specification from asciidoc source
71    containing multiple versions and extensions, by explicitly enabling
72    their inclusion.
73
74[NOTE]
75.Note
76====
77Published extensions are documented as part of the `master` branch of the
78<<vulkan-docs,KhronosGroup/Vulkan-Docs>> project.
79They can optionally be included or excluded when generating specifications.
80====
81
82There is a rigid syntax for these names:
83
84  * Versions are named with the syntax `VK_VERSION_<major>_<minor>`.
85  * Extensions are named with the syntax `VK_<author>_<name>`.
86  * Layers are named with the syntax `VK_LAYER_<author>_<name>` or
87    `VK_LAYER_<fqdn>_<name>`.
88
89All these names include a `VK_` prefix, as described in the
90<<naming-preprocessor,Preprocessor Defines>> section above.
91In addition, layers add a `LAYER_` prefix.
92
93All these names must be valid C language identifiers.
94
95
96[[extensions-naming-conventions-name-strings]]
97=== Version, Extension and Layer Name Strings
98
99The `<name>` portion of version, extension and layer names is a concise name
100describing its purpose or functionality.
101The underscore (`_`) character is used as a delimiter between words.
102Every alphabetic character of the name must be in lower case.
103
104
105[[extensions-naming-author-IDs]]
106=== Author IDs for Extensions and Layers
107
108Extension and layer names also contain an _author ID_, indicated by
109`<author>` above, identifying the author of the extension/layer.
110This ID is a short, capitalized string identifying an author, such as a
111Khronos member developing Vulkan implementations for their devices, or a
112non-Khronos developer creating Vulkan layers.
113Author IDs must be registered with Khronos.
114
115Some authors have platform communities they wish to distinguish between, and
116can register additional author IDs for that purpose.
117For example, Google has separate Android and Chrome communities.
118
119Details on how to register an author ID are provided below.
120Layer authors not wishing to register an author ID with Khronos can instead
121use a fully-qualified domain name (FQDN, indicated by `<fqdn>` above) as the
122ID.
123The FQDN should be a domain name owned by the author.
124FQDNs cannot be used for extensions, only for layers.
125
126  * The following are examples of extension and layer names, demonstrating
127    the above syntax:
128  ** Extension names all use the base prefix `VK_`.
129  ** Khronos-ratified extensions add the reserved author ID `KHR` and use
130     the prefix `VK_KHR_`.
131  ** The following author IDs are reserved and must not be used:
132  *** `VK` - To avoid confusion with the top-level `VK_` prefix.
133  *** `VULKAN` - To avoid confusion with the name of the Vulkan API.
134  *** `LAYER` - To avoid confusion with the higher-level "`LAYER`" prefix.
135  *** `KHRONOS` - To avoid confusion with the Khronos organization.
136  ** Multi-author extensions that have not been ratified by Khronos (those
137     developed via cooperation between, and intended to be supported by two
138     or more registered authors) add the special author ID `EXT` to the base
139     prefix, and will use the prefix `VK_EXT_`.
140  ** Traditional author-specific extensions developed by one author (or one
141     author in cooperation with non-authors) add the author ID to the base
142     prefix.
143     For example, NVIDIA will use the prefix `VK_NV_`, and Valve will use
144     the prefix `VK_VALVE_`.
145     Some authors can have additional registered author IDs for special
146     purposes.
147     For example, an Android extension developed by Google - but part of an
148     Android open-source community project, and so not a proprietary Google
149     extension - will use the author ID `ANDROID`.
150  ** Layer names follow the same conventions as extensions, but use the base
151     prefix `VK_LAYER_`.
152  ** Because layers need not be registered with Khronos, an alternative
153     mechanism is needed to allow creating unique layer names without
154     registering an author ID.
155     Layer authors that prefer not to register an author ID can instead use
156     a fully-qualified domain name (FQDN) in reverse-order as an author ID,
157     replacing `.` (period) with `_` (underscore) characters.
158     The restriction that layer names must be valid C identifiers means that
159     some FQDNs cannot be used as part of layer names.
160
161[NOTE]
162.Note
163====
164The `KHX` author ID was used for _experimental_ extensions, as described in
165the "`Layers & Extensions`" appendix of the <<vulkan-spec,Vulkan API
166Specification>>.
167As of the initial Vulkan 1.1 public release, all `KHX` extensions have been
168promoted to `KHR` status, and this mechanism is no longer used.
169====
170
171[source, c]
172.Example
173----
174// Core API version name for Vulkan 1.1
175VK_VERSION_1_1
176
177// Khronos extension name
178VK_KHR_mirror_clamp_to_edge
179
180// Multivendor extension name
181VK_EXT_debug_marker
182
183// Vendor extension name using author ID NV
184VK_NV_glsl_shader
185
186// Vendor layer name using author ID LUNARG
187VK_LAYER_LUNARG_vktrace
188
189// Layer name using the FQDN www.3dxcl.invalid instead of an author ID
190VK_LAYER_invalid_3dxcl_www
191----
192
193[NOTE]
194.Note
195====
196To avoid linking to a nonexistent domain, the reserved TLD `.invalid` is
197used in the example above.
198====
199
200
201[[extensions-naming]]
202== Extension Command, Type, and Token Naming Conventions
203
204Extensions may add new commands, types, and tokens, or collectively
205"`objects`", to the Vulkan API.
206These objects are given globally unique names by appending the author ID
207defined above for the extension name as described in the
208<<naming-extension-identifiers, Extension Identifier Naming Conventions>>
209section above.
210
211
212[[extensions-api-registry]]
213== The Vulkan Registry
214
215The canonical definition of the Vulkan APIs is kept in an XML file known as
216the *Vulkan registry*.
217The registry is kept in `xml/vk.xml` in the `master` branch of the
218<<vulkan-docs,KhronosGroup/Vulkan-Docs>> project, containing the most
219recently released Vulkan API specification.
220The registry contains reserved author IDs, core and extension interface
221definitions, definitions of individual commands and structures, and other
222information which must be agreed on by all implementations.
223The registry is used to maintain a single, consistent global namespace for
224the registered entities, to generate the Khronos-supplied Vulkan header
225files, and to create a variety of related documentation used in generating
226the API specification and reference pages.
227Other uses of the registry outside Khronos include the LunarG Loader and
228Validation Layers, and a variety of language bindings.
229
230
231[[extensions-author-ID]]
232== Registering an Author ID with Khronos
233
234Previous Khronos APIs could only officially be modified by Khronos members.
235In an effort to build a more flexible platform, Vulkan allows non-Khronos
236developers to extend and modify the API via layers and extensions in the
237same manner as Khronos members.
238However, extensions must still be registered with Khronos.
239A mechanism for non-members to register layers and extensions is provided.
240
241Extension authors will be able to create an account on GitHub and register
242an author ID with Khronos through the
243<<vulkan-docs,KhronosGroup/Vulkan-Docs>> project.
244The author ID must be used for any extensions that author registers.
245The same mechanism will be used to request registration of extensions or
246layers with Khronos, as described below.
247
248To reserve an author ID, propose a merge request against
249<<extensions-api-registry,`vk.xml`>> in the `master` branch.
250The merge must add a `<tag>` XML tag and fill in the `name`, `author` and
251+contact+ attributes with the requested author ID, the author's formal name
252(e.g. company or project name), and contact email address, respectively.
253The author ID will only be reserved once this merge request is accepted.
254
255Please do not try to reserve author IDs which clearly belong to another
256existing company or project which may wish to develop Vulkan extensions or
257layers in the future, as a matter of courtesy and respect.
258Khronos may decline to register author IDs that are not requested in good
259faith.
260
261
262[[extensions-vendor-id]]
263== Registering a Vendor ID with Khronos
264
265Vulkan implementers must report a valid vendor ID for their implementation
266when queried by fname:vkGetPhysicalDeviceProperties, as described in the
267"`Devices and Queues`" section of the <<vulkan-spec,Vulkan API
268Specification>>.
269If there is no valid PCI vendor ID defined for the physical device,
270implementations must obtain a Khronos vendor ID.
271
272Khronos vendor IDs are reserved in a similar fashion to
273<<extensions-author-ID,author IDs>>.
274While vendor IDs are not directly related to API extensions, the reservation
275process is similar, and so is described in this section.
276
277To reserve an Khronos vendor ID, you must first have a Khronos author ID.
278Propose a merge request against <<extensions-api-registry,`vk.xml`>> in the
279`master` branch.
280The merge must define a new enumerant by adding an `<enum>` tag to the
281`VkVendorId` `<enums>` tag, following the existing examples.
282The `value` attribute of the `<enum>` must be the next available unused
283value, and is the reserved vendor ID.
284The `name` attribute must be `VK_VENDOR_ID_<author>`, where `<author>` is
285the author tag.
286The vendor ID will be reserved only once this merge request has been
287accepted.
288
289Please do not try to reserve vendor IDs unless you are making a good faith
290effort to develop a Vulkan implementation and require one for that purpose.
291
292
293== Registering Extensions and Layers
294
295Extensions must be registered with Khronos.
296Layers should be registered, but registration is not required.
297Registration means:
298
299  * Receiving an extension number.
300  * Adding the extension or layer name to the list in `vk.xml` and appearing
301    on the Khronos registry website, which will link to associated
302    documentation hosted on Khronos.
303  * For extensions which add to the Vulkan API, including definitions of
304    those additions to `vk.xml`.
305
306Registration for Khronos members is handled by filing a merge request in the
307internal gitlab repository against the branch containing the core
308specification against which the extension or layer will be written.
309The merge must modify `vk.xml` to define extension names, API interfaces,
310and related information.
311Registration is not complete until the registry maintainer has validated and
312accepted the merge.
313
314Since this process could in principle be completely automated, this suggests
315a scalable mechanism for accepting registration of non-Khronos extensions.
316Non-Khronos members who want to create extensions must register with Khronos
317by creating a GitHub account, and registering their author ID and/or FQDNs
318to that account.
319They can then submit new extension registration requests by proposing merges
320to `vk.xml`.
321On acceptance of the merge, the extension will be registered, though its
322specification need not be checked into the Khronos GitHub repository at that
323point.
324
325The registration process can be split into several steps to accommodate
326extension number assignment prior to extension publication:
327
328  * Acquire an extension number.
329    This is done by proposing a merge request against `vk.xml` similarly to
330    how <<extensions-author-ID,author IDs are reserved>>.
331    The merge should add a new `<extension>` tag at the end of the file with
332    attributes specifying the proposed extension `name`, the next unused
333    sequential extension `number`, the `author` and `contact` information
334    (if different than that already specified for the author ID used in the
335    extension name), and finally, specifying `supported="disabled"`.
336    The extension number will be reserved only once this merge request is
337    accepted into the `master` branch.
338  * Develop and test the extension using the registered extension number.
339  * Publish the extension to Khronos using the previously registered
340    extension number, by submitting merge requests to the `master` branch
341    defining the changes specific to the extension.
342    Changes to both the specification source, and to `vk.xml` will be
343    needed.
344  ** Extension changes to the specification source must be protected by
345     asciidoc conditionals as described in the
346     <<extensions-documenting,Documenting Extensions>> section.
347  ** Changes to `vk.xml` must define the extension interfaces in the
348     `<extension>` block, and must also change the `supported` attribute
349     value of the `<extension>` to `supported="vulkan"`.
350  ** When publishing an extension, mark it as enabled by proposing a merge
351     to the `master` branch changing the `supported` attribute value of the
352     `<extension>` to `supported="vulkan"`.
353     This should be completely automated and under the control of the
354     publishers, to allow them to align publication on Khronos with product
355     releases.
356     However, complete automation might be difficult, since steps such as
357     regenerating and validating the Vulkan header files are involved.
358     Once the merge is accepted and the corresponding updated header with
359     the new extension interface is committed to the `master` branch,
360     publication is complete.
361  ** Publishing on the <<vulkan-docs,Khronos public GitHub repository>> is
362     preferred whenever possible.
363     Khronos members may instead create branches on Khronos' internal gitlab
364     server, but those branches will eventually be mirrored to GitHub.
365  ** Once the merge request defining an extension has been accepted into the
366     `master` branch, publication is complete - although it may not be
367     visible on GitHub until the next regular core Specification update is
368     pushed out.
369  * It is still possible to publish a separate branch of the repository with
370    appropriate changes relative to the core Vulkan API branch instead, but
371    this approach is deprecated and discouraged.
372    If this is done, all changes to `vk.xml` must still be made in the
373    `master` branch.
374
375ifdef::editing-notes[]
376[NOTE]
377.editing-note
378====
379TODO: This section is subject to change and not complete yet, but in broad
380is how we expect extension registration and specifications to work.
381The process will be refined as members and outside authors define further
382extensions.
383====
384endif::editing-notes[]
385
386
387[[extensions-documenting]]
388== Documenting API Versions and Extensions
389
390API versions and extensions are documented as modifications to the Vulkan
391specification.
392Changes specific to a version or extension are protected by asciidoc
393conditionals.
394The changes are only visible in generated documentation when the
395Specification is built with an asciidoc attribute of that name defined.
396
397For example, the `VK_KHR_surface` extension is now documented in the
398`master` branch of the GitHub `<<vulkan-docs,KhronosGroup/Vulkan-Docs>>`
399project.
400However, specifications generated from this branch will only include the
401extension when the Makefile is invoked appropriately.
402
403
404[[extensions-documenting-extensions]]
405=== Changes for New Extensions
406
407Most language defining extensions can be localized either into a small
408number of asciidoc include files which are conditionally included in the
409core specification chapters and appendices, or into parts of `vk.xml`
410defining the extension interfaces.
411
412[NOTE]
413.Note
414====
415We do not yet fully document an example of including a new version or
416extension.
417New versions are authored only by Khronos and examples will be available at
418such time that we publish a new version.
419Extension authors should refer to the `master` branch and search for the
420names of existing extensions, such as `VK_KHR_surface`, for markup examples.
421Some aspects of the changes for this example extension are described below.
422====
423
424Changes for extensions include (but may not be limited to) the following:
425
426  * All extensions must add an appendix to the Vulkan specification.
427    The appendix should be modeled after the `VK_KHR_shader_draw_parameters`
428    extension in `appendices/VK_KHR_shader_draw_parameters.txt`, which
429    contains metainformation about the extension (as well as code examples,
430    and revision history).
431    This example is complicated because `VK_KHR_shader_draw_parameters` has
432    a variety of external dependencies and interactions.
433    The `VK_EXT_debug_marker` extension is a simpler, standalone example.
434  * In the preamble to the appendix, start with an asciidoc `include` of the
435    automatically generated meta information.
436    This information includes the extension name string, type, number,
437    revision, and contact information from +vk.xml+.
438  * Following the `include`, add as many of the following sections as are
439    meaningful:
440  ** *Status* - *Complete*, *Draft*, or other.
441     When an extension is published in the `master` branch, it is normally
442     assumed to be complete; the *Status* field should be removed at this
443     time, unless it contains additional information.
444  ** *Last Modified Date* - if wanted, although git log queries can provide
445     equivalent information.
446  ** *IP Status* - Such as *No known IP claims*.
447  ** *Interactions and External Dependencies* - may include requirements or
448     interactions with optional Vulkan features, SPIR-V (+SPV+) and OpenGL
449     extensions, and interactions (other than strictly requiring) with other
450     Vulkan extensions.
451  ** *Contributors* - Names and corporate affiliations of people who have
452     made significant direct contributions to this extension.
453  * Each extension's appendix file is automatically included from
454    `appendices/extensions.txt` via code generated from `vk.xml`.
455    It is no longer neccessary to explicit include the appendices.
456  * Extensions usually make significant additions and changes to the Vulkan
457    specification.
458    They often add an entirely new chapter, or a new section of an existing
459    chapter, defining the new functions, structures, and enumerants.
460    For example, in the case of `VK_EXT_debug_marker`, it adds a new section
461    of the "`Debugging`" chapter in `chapters/debugging.txt`, by including
462    in that file:
463+
464[source,asciidoc]
465.Example Markup
466----
467\ifdef::VK_EXT_debug_marker[]
468\include::chapters/VK_EXT_debug_marker/wsi.txt[]
469\endif::VK_EXT_debug_marker[]
470----
471  * In every other place where the extension alters the behavior of the core
472    Specification, make such changes and protect the modifications with the
473    same asciidoc conditionals.
474    For example, `VK_KHR_surface` adds new error codes to Vulkan.
475    These are added to `chapters/fundamentals.txt` in the "`Return Codes`"
476    section as follows:
477+
478[source,asciidoc]
479.Example Markup
480----
481... list of existing error codes
482\ifdef::VK_KHR_surface[]
483\include::VK_KHR_surface/VkResultErrorDescriptions_surface.txt[]
484\endif::VK_KHR_surface[]
485----
486  * If two extensions interact, the asciidoc conditionals must be carefully
487    structured so as to properly document the interactions if the
488    specification is built with both extensions.
489    Asciidoc conditionals allow "and" and "or" constructs (see:
490    http://asciidoctor.org/docs/user-manual/#conditional-preprocessor-directives
491    and
492    http://asciidoctor.org/docs/user-manual/#checking-multiple-attributes-ifdef-and-ifndef-only).
493+
494[source,asciidoc]
495.Example Markup
496----
497\ifdef::VK_KHR_foo[]
498... discussion of VK_KHR_foo ...
499\ifdef::VK_KHR_fum[]
500... discussion of interactions between VK_KHR_foo and VK_KHR_fum ...
501\endif::VK_KHR_fum[]
502\endif::VK_KHR_foo[]
503
504\ifdef::VK_KHR_fum[]
505... discussion of VK_KHR_fum ...
506\endif::VK_KHR_fum[]
507----
508  * In cases where a new extension (A) modifies both core and an existing
509    extension (B), if the new extension (A) becomes part of the core at a
510    future release (i.e. is no longer an extension), the portion of the new
511    extension that modified the existing extension (B) effectively becomes
512    part of that existing extension.
513    Thus, at the new core release, enabling the pre-existing extension (B)
514    also enables the functionality that was previously enabled by enabling
515    the previously-new extension (A).
516  * For vendor extensions, changes made to existing core Specification
517    source files and to `vk.xml` all fall under the Contributor License
518    Agreement.
519    Vendors may use their own copyright on new files they add to the
520    `master` branch, although that copyright must be compatible with the
521    Specification copyright.
522  * In most cases, there will be at most two new files added to the
523    specification: `extensions/*extension_name*.txt`, and
524    `chapters/*extension_name*.txt`.
525    If you need more than one new file in either the `chapters/` or
526    `extensions/` directories, create a subdirectory named with the
527    extension name and place the new files there.
528    For example, instead of `chapters/VK_KHR_android_surface.txt`, there is
529    `chapters/VK_KHR_android_surface/platformCreateSurface_android.txt` and
530    `chapters/VK_KHR_android_surface/platformQuerySupport_android.txt`, both
531    of which are conditionally included elsewhere in the core specification
532    files.
533  * Valid Usage statements referring to interactions between structures in a
534    pname:pNext chain must be described in the parent structure's language,
535    as specified <<extensions-interactions-parent, in more detail below>>.
536  * Valid Usage statements must: be kept atomic with regards to extension
537    conditionals - do not surround part of a single statement with
538    conditionals.
539    Valid usage statements are automatically extracted from the
540    specification for use by ecosystem components like the validation
541    layers, and the extraction scripts need to know which valid usage
542    statements apply to which extensions.
543    The loops required to deal with partial statements are simply not worth
544    the trouble.
545    For example, instead of
546+
547[source,asciidoc]
548.Example Markup
549----
550  * If pname:buffer was created with a sharing mode of
551    ename:VK_SHARING_MODE_EXCLUSIVE, pname:srcQueueFamilyIndex and
552    pname:dstQueueFamilyIndex must: either both be
553    ename:VK_QUEUE_FAMILY_IGNORED, or both be a valid queue family (see
554    <<devsandqueues-queueprops>>)
555\ifdef::VK_KHR_external_memory[]
556    unless one of them is ename:VK_QUEUE_FAMILY_EXTERNAL_KHR and the other
557    is ename:VK_QUEUE_FAMILY_IGNORED.
558\endif::VK_KHR_external_memory[]
559----
560+
561Use
562+
563[source,asciidoc]
564.Example Markup
565----
566ifndef::VK_KHR_external_memory[]
567  * If pname:buffer was created with a sharing mode of
568    ename:VK_SHARING_MODE_EXCLUSIVE, pname:srcQueueFamilyIndex and
569    pname:dstQueueFamilyIndex must: either both be
570    ename:VK_QUEUE_FAMILY_IGNORED, or both be a valid queue family (see
571    <<devsandqueues-queueprops>>)
572endif::VK_KHR_external_memory[]
573ifdef::VK_KHR_external_memory[]
574  * If pname:buffer was created with a sharing mode of
575    ename:VK_SHARING_MODE_EXCLUSIVE, pname:srcQueueFamilyIndex and
576    pname:dstQueueFamilyIndex must: either both be
577    ename:VK_QUEUE_FAMILY_IGNORED, both be a valid queue family (see
578    <<devsandqueues-queueprops>>), or be
579    ename:VK_QUEUE_FAMILY_EXTERNAL_KHR and ename:VK_QUEUE_FAMILY_IGNORED in
580    either order
581endif::VK_KHR_external_memory[]
582----
583
584
585[[extensions-documenting-versions]]
586=== Changes for New API Versions
587
588When creating a new version of the core API, such as Vulkan 1.1, changes are
589done similarly to extensions, with the following differences:
590
591[NOTE]
592.Note
593====
594This list is being developed in conjunction with the Vulkan 1.1
595Specification, is probably incomplete, and is subject to change.
596Items marked *TBD* are still being discussed within the Vulkan Working
597Group.
598====
599
600  * New API versions will be more tightly integrated into the specification
601    sources than extensions, although it's still helpful to partition
602    changes into new files when they're sufficiently self-contained.
603  * New API versions must add an appendix to the Vulkan specification.
604    Unlike the extension appendices, this appendix simply summarizes release
605    information (dates of Ratification by the Khronos Board of Promoters,
606    and of public release), the contributor list, and high-level
607    descriptions of new features in this version (including the names of any
608    extensions promoted to core status in this version).
609  ** TBD - we might choose to include a new API summary with links into the
610     spec body for new features, as well.
611  * TBD - how to name and where to include this appendix file.
612  * Changes to the Specification for new versions will range from small
613    changes to existing language, to new commands and structures, to adding
614    entire new chapters.
615    New chapters must be defined in separate files under the `chapters/`
616    directory, and included at an appropriate point in `vkspec.txt` or other
617    specification source files.
618    Other changes and additions are included inline in existing chapters.
619  * All changes that are specific to the new version must be protected by
620    the asciidoc conditional (e.g. the version name).
621    For example, in the case of Vulkan 1.1:
622+
623+
624[source,asciidoc]
625.Example Markup
626----
627Add a new chapter:
628
629\ifdef::VK_VERSION_1_1[]
630\include::chapters/newchapter11.txt[]
631\endif::VK_VERSION_1_1[]
632
633Add a new feature:
634
635\ifdef::VK_VERSION_1_1[]
636... language describing the new command, structure, or enumeration
637\endif::VK_VERSION_1_1[]
638----
639  * The specification must continue to be a valid document when the new
640    version is *not* defined, so that (for example) the Vulkan 1.1 branch
641    specification can continue to be updated.
642  * TBD - how to deprecate extensions which have been promoted to core
643    status in the new version, while continuing to have those extensions
644    appear then older versions of the specification are being built.
645  * The same constraints <<extensions-documenting-extensions, described
646    above>> for Valid Usage statements modified by extensions apply for new
647    versions.
648
649
650== Assigning Extension Token Values
651
652Extensions can define their own enumeration types and assign any values to
653their enumerants that they like.
654Each enumeration has a private namespace, so collisions are not a problem.
655However, when extending existing enumeration objects with new values, care
656must be taken to preserve global uniqueness of values.
657Enumerations which define new bits in a bitmask are treated specially as
658described in <<extensions-reserving-bitmask-values,Reserving Bitmask
659Values>> below.
660
661Each extension is assigned a range of values that can be used to create
662globally-unique enum values.
663Most values will be negative numbers, but positive numbers are also
664reserved.
665The ability to create both positive and negative extension values is
666necessary to enable extending enumerations such as etext:VkResult that
667assign special meaning to negative and positive values.
668Therefore, 1000 positive and 1000 negative values are reserved for each
669extension.
670Extensions must not define enum values outside their reserved range without
671explicit permission from the owner of those values (e.g. from the author of
672another extension whose range is infringed on, or from the Khronos Registrar
673if the values do not belong to any extension's range).
674
675[NOTE]
676.Note
677====
678Typically, extensions use a unique offset for each enumeration constant they
679add, yielding 1000 distinct token values per extension.
680Since each enumeration object has its own namespace, if an extension needs
681to add many enumeration constant values, it can reuse offsets on a per-type
682basis.
683====
684
685The information needed to add new values to the XML are as follows:
686
687  * The **extension name** (e.g. `VK_KHR_swapchain`) that is adding the new
688    enumeration constant.
689  * The existing enumeration **type** being extended (e.g.
690    stext:VkStructureType).
691  * The name of the new enumeration **token** being added (e.g.
692    etext:VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR).
693  * The **offset**, which is an integer between 0 and 999 relative to the
694    base being used for the extension.
695  * The **direction** may be specified to indicate a negative value
696    (`dir="-"`) when needed for negative etext:VkResult values indicating
697    errors, like etext:VK_ERROR_SURFACE_LOST_KHR.
698    The default direction is positive, if not specified.
699
700Implicit is the registered number of an extension, which is used to create a
701range of unused values offset against a global extension base value.
702Individual enumerant values are calculated as offsets in that range.
703Values are calculated as follows:
704
705  * [eq]#_base_value_ = 1000000000#
706  * [eq]#_range_size_ = 1000#
707  * [eq]#enum_offset(_extension_number_, _offset_) = _base_value_ {plus}
708    (_extension_number_ - 1) {times} _range_size_ + _offset_#
709  * Positive values: [eq]#enum_offset(_extension_number_, _offset_})#
710  * Negative values: [eq]#enum_offset(_extension_number_, _offset_})#
711
712The exact syntax for specifying extension enumerant values is defined in the
713`readme.pdf` specifying the format of `vk.xml`, and extension authors can
714also refer to existing extensions for examples.
715
716If an extension becomes part of core, the enumerant values should remain the
717same as they were in the original extension, in order to maintain binary
718compatibility with existing applications.
719
720
721[[extensions-reserving-bitmask-values]]
722=== Reserving Bitmask Values
723
724Enumerants which define bitmask values are a special case, since there are
725only a small number of unused bits available for extensions.
726For core Vulkan API and KHR extension bitmask types, reservations must be
727approved by a vote of the Vulkan Working Group.
728For EXT and vendor extension bitmask types, reservations must be approved by
729the listed contact of the extension.
730Bits are not reserved, and must not be used in a published implementation or
731specification until the reservation is merged into
732<<extensions-api-registry,+vk.xml+>> by the registry maintainer.
733
734
735== Required Extension Tokens
736
737In addition to any tokens specific to the functionality of an extension, all
738extensions must define two additional tokens.
739
740  * `VK_EXTNAME_SPEC_VERSION` is an integer constant which is the revision
741    of the extension named `VK_extname` (`EXTNAME` is all upper-case, while
742    extname is the capitalization of the actual extension name).
743    This value begins at 1 with the initial version of an extension
744    specification, and is incremented when changes are made.
745    Note that the revision of an extension defined in the Vulkan header
746    files and the revision supported by the Vulkan implementation (the
747    pname:specVersion field of the slink:VkExtensionProperties structure
748    corresponding to the extension and returned by one of the
749    <<extended-functionality-extensions,extension queries>>) may differ.
750    The revision value indicates a patch version of the extension
751    specification, and differences in this version number maintain full
752    compatibility, as defined in the
753    link:html/vkspec.html#fundamentals-versionnum[API Version Numbers and
754    Semantics] section of the <<vulkan-spec,Vulkan API Specification>>.
755
756[NOTE]
757.Note
758====
759Any changes requiring the addition or removal of a type or command should be
760done by creating a new extension.
761The resulting extension should take care to include the appropriate
762dependency information on the original extension.
763====
764
765[NOTE]
766.Note
767====
768When the Debug Report extension (VK_EXT_debug_report) was recently updated
769to include the enum values of VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT
770and VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT, we violated this
771policy.
772That change was done prior to this revision policy clarification.
773From this point forward, we intend to follow this policy.
774====
775
776  * `VK_EXTNAME_EXTENSION_NAME` is a string constant which is the name of
777    the extension.
778
779For example, for the WSI extension `VK_KHR_surface`, at the time of writing
780the following definitions were in effect:
781
782[source,c]
783----
784#define VK_KHR_SURFACE_SPEC_VERSION 24
785#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface"
786----
787
788
789== Extension Handles, Objects, Enums, and Typedefs
790
791Expanding on previous discussion, extensions can add values to existing
792enums; and can add their own commands, enums, typedefs, etc.
793This is done by adding to <<extensions-api-registry,+vk.xml+>>.
794All such additions will be included in the Vulkan header files supplied by
795Khronos.
796
797If the extension adds a new handle to Vulkan, a corresponding value must be
798added to ename:VkObjectType (as defined in the "`Debugging`" section of the
799<<vulkan-spec,Vulkan API Specification>>) in order to allow components to
800identify and track objects of the new type.
801
802The new enumeration value must conform to the naming defined in the
803<<extension-enumerant-names,Extension Enumerant Names>> section.
804In this case, the type's etext:Vk prefix is replaced with the enum prefix
805etext:VK_OBJECT_TYPE_, and the rest of the handle name is converted as
806described in that section.
807
808[source,asciidoc]
809.Conversion of Handle to VkObjectType Examples:
810----
811 VkSurfaceKHR                  -> VK_OBJECT_TYPE_SURFACE_KHR
812 VkDescriptorUpdateTemplateKHR -> VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR
813----
814
815[NOTE]
816.Note
817====
818Application developers are encouraged to be careful when using `switch`
819statements with Vulkan API enums.
820This is because extensions can add new values to existing enums.
821The use of a `default:` statement, within a `switch`, may avoid future
822compilation issues.
823====
824
825[[extension-function_prototypes]]
826== Extension Function Prototypes
827
828Function pointer declarations and function prototypes for all core Vulkan
829API commands are included in the Vulkan header files.
830These come from the official XML specification of the Vulkan API hosted by
831Khronos.
832
833Function pointer declarations are also included in the Vulkan header for all
834commands defined by registered extensions.
835Function prototypes for extensions may be included in the headers.
836Extension commands that are part of the Vulkan ABI must be flagged in the
837XML.
838Function prototypes will be included in the headers for all extension
839commands that are part of the Vulkan ABI.
840
841An extension can be considered platform specific, in which case its
842interfaces in the header files are protected by #ifdefs.
843This is orthogonal to whether an extension command is considered to be part
844of the Vulkan ABI.
845
846The initial set of WSI extension commands (i.e. for `VK_KHR_surface`,
847`VK_KHR_swapchain`, and `VK_KHR_*_surface`) are considered to be part of the
848Vulkan ABI.
849Function prototypes for these WSI commands are included in platform-specific
850files such as `vulkan_android.h`.
851See the "`Window System-Specific Header Control (Informative)`" section of
852the Vulkan Specification for more details.
853
854[NOTE]
855.Note
856====
857Based on feedback from implementers, Khronos expects the Android, Linux, and
858Windows Vulkan SDKs to include our header files, and export the supported
859WSI functions for those platforms from their loader libraries.
860Other implementations can make different choices for their headers and
861loader libraries, but are encouraged to be consistent with these
862implementations.
863====
864
865
866== Accessing Extension Functions from Programs
867
868flink:vkGetInstanceProcAddr and flink:vkGetDeviceProcAddr can be used in
869order to obtain function pointer addresses for core and extension commands
870(per the description in the "`Command Function Pointers`" section of the
871<<vulkan-spec,Vulkan API Specification>>).
872Different Vulkan API loaders can choose to statically export functions for
873some or all of the core Vulkan API commands, and can statically export
874functions for some or all extension commands.
875If a loader statically exports a function, an application can link against
876that function without needing to call one of the ftext:vkGet*ProcAddr
877commands.
878
879[NOTE]
880.Note
881====
882The Vulkan API loader for Android, Linux, and Windows exports functions for
883all core Vulkan API commands, and for a set of WSI extension commands that
884are applicable to those operating systems (see Vulkan loader documentation
885for the relevant platform/OS for details).
886The WSI functions are considered special, because they are required for many
887applications.
888====
889
890
891[[extensions-interactions]]
892== Extension Interactions
893
894Extensions modifying the behavior of existing commands should provide
895additional parameters by using the pname:pNext field of an existing
896structure, pointing to a new structure defined by the extension, as
897described in the "`Valid Usage`" section of the <<vulkan-spec,Vulkan API
898Specification>>.
899Extension structures defined by multiple extensions affecting the same
900structure can be chained together in this fashion.
901Any structure which can be chained in this fashion must begin with the
902following two members:
903
904["source","c++",title=""]
905----
906VkStructureType        sType;
907const void*            pNext;
908----
909
910It is in principle possible for extensions to provide additional parameters
911through alternate means, such as passing a handle parameter to a structure
912with a pname:sType defined by the extension, but this approach is
913discouraged and should not be used.
914
915When chaining multiple extensions to a structure, the implementation will
916process the chain starting with the base parameter and proceeding through
917each successive chained structure in turn.
918Extensions should be defined to accept any order of chaining, and must
919define their interactions with other extensions such that the results are
920deterministic.
921If an extension needs a specific ordering of its extension structure with
922respect to other extensions in a chain to provide deterministic results, it
923must define the required ordering and expected behavior as part of its
924specification.
925
926Validation of such extended structure chains is automatically generated from
927the registry, as described in the description of attr:structextends in
928link:registry.html[the registry document].
929
930
931[[extensions-interactions-parent]]
932== Valid Usage and Extension pname:pNext Chains
933
934When there is a Valid Usage interaction between a parent structure and
935another structure appearing in the pname:pNext chain of the parent, that
936interaction must: be described in the explicit Valid Usage section of the
937parent structure, rather than the chained structure, and must: be protected
938by appropriate extension-specific `ifdef` constructs.
939
940For example, a constraint added to the slink:VkImageCreateInfo structure by
941the presence of two extensions which cannot interact is properly described
942as:
943
944[source,asciidoc]
945.Example Markup
946----
947// CORRECT: define interaction with children in parent VkImageCreateInfo
948// structure
949\ifdef::VK_NV_external_memory+VK_KHR_external_memory[]
950  * If the pname:pNext chain contains an instance of
951    slink:VkExternalMemoryImageCreateInfoNV, it must: not contain an
952    instance of slink:VkExternalMemoryImageCreateInfoKHR.
953\endif::VK_NV_external_memory+VK_KHR_external_memory[]
954----
955
956However, a constraint added to slink:VkBufferCreateInfo by a structure in
957the `VK_NV_dedicated_allocation` extension must not be described as part of
958that structure's valid usage:
959
960[source,asciidoc]
961.Example Markup
962----
963// WRONG! Do not define interaction with parent in child
964// VkDedicatedAllocationBufferCreateInfoNV structure
965  * If pname:dedicatedAllocation is ename:VK_TRUE,
966    sname:VkBufferCreateInfo::pname:flags must: not include
967    ename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT,
968    ename:VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT, or
969    ename:VK_BUFFER_CREATE_SPARSE_ALIASED_BIT
970----
971
972Instead, define the constraint as part of the parent
973slink:VkBufferCreateInfo structure's valid usage:
974
975[source,asciidoc]
976.Example Markup
977----
978// REWRITTEN CORRECTLY: Define interaction with child in
979// parent VkBufferCreateInfo structure
980\ifdef::VK_NV_dedicated_allocation[]
981  * If the pname:pNext chain contains an instance of
982    slink:VkDedicatedAllocationBufferCreateInfoNV, and the
983    pname:dedicatedAllocation member of the chained structure is
984    ename:VK_TRUE, then pname:flags must: not include
985    ename:VK_BUFFER_CREATE_SPARSE_BINDING_BIT,
986    ename:VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT, or
987    ename:VK_BUFFER_CREATE_SPARSE_ALIASED_BIT
988\endif::VK_NV_dedicated_allocation[]
989----
990