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