1// Copyright (c) 2013-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= The Khronos Vulkan^(R)^ API Registry 6Jon Leech 7:data-uri: 8:icons: font 9:toc2: 10:toclevels: 3 11:max-width: 100 12:numbered: 13:doctype: book 14:imagewidth: 800 15:fullimagewidth: width="800" 16:cl: : 17 18// Various special / math symbols. This is easier to edit with than Unicode. 19include::config/attribs.txt[] 20 21:leveloffset: 1 22 23<<<< 24 25include::copyright-ccby.txt[] 26 27<<<< 28 29[[introduction]] 30= Introduction 31 32This document describes the Khronos Vulkan API Registry schema, and 33provides some additional information about using the registry and 34scripts to generate a variety of outputs, including C header files as 35well as several types of asciidoc include files used in the Vulkan API 36specification and reference pages. The underlying XML files and scripts 37are located on the Khronos public Github server at URL 38 39https://github.com/KhronosGroup/Vulkan-Docs 40 41The authoritative copy of the Registry is maintained in the `master` branch. 42 43[NOTE] 44.Note 45==== 46The older version of the registry in the `1.0` branch is out of date. 47==== 48 49The registry uses an XML representation of the Vulkan API, together with 50a set of Python scripts to manipulate the registry once loaded. The 51scripts rely on the Python `etree` package to parse and operate on XML. 52An XML schema and validator target are included. 53 54The schema is based on, but not identical to that used for the previously 55published OpenGL, OpenGL ES and EGL API registries. It was extended to 56represent additional types and concepts not needed for those APIs, such as 57structure and enumerant types, as well as additional types 58of registered information specific to Vulkan. 59 60The Vulkan C header files generated from the registry are checked in under 61`include/vulkan/`. 62 63 64== Schema Choices 65 66The XML schema is not pure XML all the way down. In particular, command 67return types/names and parameters, and structure members, are described in 68mixed-mode tag containing C declarations of the appropriate information, 69with some XML nodes annotating particular parts of the declaration such as 70its base type and name. This choice is based on prior experience with the 71SGI `.spec` file format used to describe OpenGL, and greatly eases human 72reading and writing the XML, and generating C-oriented output. The cost is 73that people writing output generators for other languages will have to 74include enough logic to parse the C declarations and extract the relevant 75information. 76 77People who do not find the supplied Python scripts to suit their needs 78are likely to write their own parsers, interpreters, and/or converters 79operating on the registry XML. We hope that we have provided enough 80information in this document, the RNC schema (`registry.rnc`), and 81comments in the Registry (`vk.xml`) itself to enable such projects. If 82not and you need clarifications; if you have other problems using the 83registry; or if you have proposed changes and enhancements, then please 84file issues on Khronos' public Github project at 85 86https://github.com/KhronosGroup/Vulkan-Docs/issues 87 88Please tag your issues with `[Registry]` in the subject line to help us 89categorize them. We have considered separating the registry from the 90specification source into a separate repository, but since there is so 91much specification valid usage language imbedded in the registry XML, 92this is unlikely to happen. 93 94 95[[starting]] 96= Getting Started 97 98See 99https://gitlab.khronos.org/vulkan/vulkan/blob/master/xml/README.adoc[`xml/README.adoc`] 100in the `Vulkan-Docs` repository for information on required toolchain 101components such as Python 3, pass:[g++], and GNU make. 102 103Once you have the right tools installed, perform the following steps: 104 105 * Check out the `Vulkan-Docs` repository linked above from Khronos 106 Github (there are instructions at the link) 107 * `cd` to the root directory in your checked-out repo 108 * Switch to the `master` branch. 109 * Invoke `make clean ; make install ; make test` 110 111This should regenerate `vulkan_core.h` and a variety of platform-specific 112headers, install them in `../include/vulkan/`, and verify that the headers build 113properly. The result should be identical to the version you just pulled from 114Github. They can be compared by, for example: 115 116`git diff ../include/vulkan/` 117 118The `install` target also generates source code for a simple extension 119loader library in `../src/ext_loader/`. 120 121Other Makefile targets in `xml/` include: 122 123 * `validate` - validate `vk.xml` against the XML schema. Recommended 124 if you are making nontrivial changes. 125 * The asciidoc includes used by the Specification and Reference Pages 126 are built using the 'make generated' target in the parent directory Makefile, 127 although they use the scripts and XML in this directory. These files 128 are generated dynamically when building the specs, since their 129 contents depend on the exact set of extensions the Specification is 130 being built to include. 131 132If you just want to modify the API, changing `vk.xml` and running `make` 133should be all that is needed. See <<examples>> for some examples of 134modifying the XML. 135 136If you want to use the registry for reasons other than generating the 137header file, extension loader, and asciidoc includes, or to generate 138headers for languages other than C, start with the Makefile rules and 139the files `vk.xml`, `genvk.py`, `reg.py`, and `generator.py`. 140 141If you are using other platforms, issues or merge requests with additional 142documentation on using the tools on those platforms would be very helpful. 143 144 145== Header Generation Script - `genvk.py` 146 147When generating header files using the `genvk.py` script, an API name 148and profile name are required, as shown in the Makefile examples. 149Additionally, specific API versions and extensions can be required or 150excluded. Based on this information, the generator script extracts the 151relevant interfaces and creates a C-language header file for them. 152`genvk.py` contains predefined generator options for the current Vulkan 153Specification release. 154 155The generator script is intended to be generalizable to other languages by 156writing new generator classes. Such generators would have to rewrite the C 157types and definitions in the XML to something appropriate to their language. 158 159 160== Registry Processing Script - `reg.py` 161 162XML processing is done in `reg.py`, which contains several objects and 163methods for loading registries and extracting interfaces and extensions for 164use in header generation. There is some internal documentation in the form 165of comments, although nothing more extensive exists yet. 166 167 168== Output Generator Script - `generator.py` 169 170Once the registry is loaded, the `COutputGenerator` class defined in 171`generator.py` is used to create a header file. The 172`DocOutputGenerator` class is used to create the asciidoc include 173files. Output generators for other purposes can be added as needed. 174There are a variety of output generators included: 175 176 * `cgenerator.py` - generate C header file 177 * `docgenerator.py` - generate asciidoc includes for APIs 178 * `hostsyncgenerator.py` - generate host sync table includes for APIs 179 * `validitygenerator.py` - generate validity language includes 180 * `pygenerator.py` - generate a Python dictionary-based encoding of 181 portions of the registry, used during spec generation 182 * `extensionStubSource.py` - generate a simple C extension loader. 183 184 185[[schema]] 186= Vulkan Registry Schema 187 188The format of the Vulkan registry is a top level tag:registry tag 189containing tag:types, tag:enums, tag:commands, tag:feature, and 190tag:extension tags describing the different elements of an API, as 191explained below. 192This description corresponds to a formal Relax NG schema file, 193`registry.rnc`, against which the XML registry files can be validated. 194 195At present the only registry in this schema is the core Vulkan API registry, 196`vk.xml`. 197 198 199[[schema:profile]] 200== Profiles 201 202Types and enumerants can have different definitions depending on the API 203profile requested. This capability is not used in the current Vulkan API but 204may be in the future. Features and extensions can include some elements 205conditionally depending on the API profile requested. 206 207 208[[schema:apiname]] 209== API Names 210 211The schema supports, but does not currently use an attr:api attribute on 212several tags. This is an arbitrary string, specified at header generation 213time, for labelling properties of a specific API or API profile. The string 214can be, but is not necessarily, an actual API name. Names starting with `vk` 215are suggested if and when we start defining profiles of Vulkan. 216 217 218[[schema:root]] 219= Registry Root (tag:registry tag) 220 221A tag:registry contains the entire definition of one or more related 222APIs. 223 224== Attributes of tag:registry tags 225 226None. 227 228== Contents of tag:registry tags 229 230Zero or more of each of the following tags, normally in this order 231(although order should not be important): 232 233 * tag:comment - Contains arbitrary text, such as a copyright 234 statement. 235 * <<tag-platforms,tag:platforms>> - defines platform names corresponding 236 to platform-specific <<tag-extension,API extensions>>. 237 * <<tag-tags,tag:tags>> - defines author IDs used for 238 extensions and layers. 239 Author IDs are described in detail in the "`Layers & Extensions`" 240 section of the "`Vulkan Documentation and Extensions: Procedures and 241 Conventions`" document. 242 * <<tag-types,tag:types>> - defines API types. Usually only one 243 tag is used. 244 * <<tag-enums,tag:enums>> - defines API token names and values. 245 Usually multiple tags are used. Related groups may be tagged as an 246 enumerated type corresponding to a tag:type tag, and resulting in a 247 C `enum` declaration. This ability is heavily used in the Vulkan 248 API. 249 * <<tag-commands,tag:commands>> - defines API commands 250 (functions). Usually only one tag is used. 251 * <<tag-feature,tag:feature>> - defines API feature interfaces 252 (API versions, more or less). One tag per feature set. 253 * <<tag-extensions,tag:extensions>> - defines API extension 254 interfaces. Usually only one tag is used, wrapping many extensions. 255 256 257[[tag-comment]] 258=== Comment Tags (tag:comment tag) 259 260A tag:comment tag contains an arbitrary string, and is unused. 261Comment tags may appear in multiple places in the schema, as described 262below. 263Comment tags are removed by output generators if they would otherwise appear 264in generated headers, asciidoc include files, etc. 265 266 267[[tag-platforms]] 268= Platform Name Blocks (tag:platforms tag) 269 270A tag:platforms contains descriptions of platform IDs for platforms 271supported by window system-specific extensions to Vulkan. 272 273== Attributes of tag:platforms tags 274 275 * attr:comment - optional. Arbitrary string (unused). 276 277== Contents of tag:platforms tags 278 279Zero or more tag:platform tags, in arbitrary order (though they are 280typically ordered by sorting on the platform name). 281 282 283[[tag-platform]] 284= Platform Names (tag:platform tag) 285 286A tag:platform tag describes a single platform name. 287 288== Attributes of tag:platform tags 289 290 * attr:name - required. 291 The platform name. 292 This must be a short alphanumeric string corresponding to the platform 293 name, valid as part of a C99 identifier. 294 Lower-case is preferred. 295 In some cases, it may be desirable to distinguish a subset of platform 296 functionality from the entire platform. 297 In these cases, the platform name should begin with the entire platform 298 name, followed by `_` and the subset name. 299+ 300-- 301[NOTE] 302.Note 303==== 304For example, 305 306`name="xlib"` 307 308is used for the X Window System, Xlib client library platform. 309 310`name="xlib_xrandr"` 311 312is used for the XRandR functionality within the `xlib` platform. 313==== 314-- 315 * attr:protect - required. 316 This must be a C99 preprocessor token beginning with `VK_USE_PLATFORM_` 317 followed by the platform name, converted to upper case, followed by `_` 318 and the extension suffix of the corresponding window system-specific 319 extension supporting the platform. 320+ 321-- 322[NOTE] 323.Note 324==== 325For example, 326 327`protect="VK_USE_PLATFORM_XLIB_XRANDR_EXT"` 328 329is used for the `xlib_xrandr` platform name. 330==== 331-- 332 * attr:comment - optional. Arbitrary string (unused). 333 334== Contents of tag:platform tags 335 336No contents are allowed. All information is contained in the attributes. 337 338 339[[tag-tags]] 340= Author ID Blocks (tag:tags tag) 341 342A tag:tags tag contains tag:authorid tags describing reserved author IDs 343used by extension and layer authors. 344 345== Attributes of tag:tags tags 346 347 * attr:comment - optional. Arbitrary string (unused). 348 349== Contents of tag:tags tags 350 351Zero or more tag:tag tags, in arbitrary order (though they are typically 352ordered by sorting on the author ID). 353 354 355[[tag-tag]] 356= Author IDs (tag:tag tag) 357 358A tag:tag tag contains information defining a single author ID. 359 360== Attributes of tag:tag tags 361 362 * attr:name - required. The author ID, as registered with Khronos. 363 A short, upper-case string, usually an abbreviation of an author, 364 project or company name. 365 * attr:author - required. 366 The author name, such as a full company or project name. 367 * attr:contact - required. 368 The contact who registered or is currently responsible for extensions 369 and layers using the ID, including sufficient contact information to 370 reach the contact such as individual name together with email address, 371 Github username, or other contact information. 372 373== Contents of tag:tag tags 374 375No contents are allowed. All information is contained in the attributes. 376 377 378[[tag-types]] 379= API Type Blocks (tag:types tag) 380 381A tag:types tag contains definitions of derived types used in the API. 382 383== Attributes of tag:types tags 384 385 * attr:comment - optional. Arbitrary string (unused). 386 387== Contents of tag:types tags 388 389Zero or more tag:type and tag:comment tags, in arbitrary order (though they 390are typically ordered by putting dependencies of other types earlier in the 391list). 392The tag:comment tags are used mostly to indicate grouping of related types. 393 394 395[[tag-type]] 396= API Type (tag:type tag) 397 398A tag:type tag contains information which can be used to generate C code 399corresponding to the type. In many cases, this is simply legal C code, with 400attributes or embedded tags denoting the type name and other types used in 401defining this type. In some cases, additional attribute and embedded type 402information is used to generate more complicated C types. 403 404== Attributes of tag:type tags 405 406 * attr:requires - optional. Another type name this type requires to 407 complete its definition. 408 * attr:name - optional. Name of this type (if not defined in the tag 409 body). 410 * attr:alias - optional. Another type name which this type is an alias of. 411 Must match the name of another tag:type element. This is typically used 412 when promoting a type defined by an extension to a new core version of 413 the API. The old extension type is still defined, but as an alias of the 414 new type. 415 * attr:api - optional. An API name (see tag:feature below) which 416 specializes this definition of the named type, so that the same API 417 types may have different definitions for e.g. GL ES and GL. This is 418 unlikely to be used in Vulkan, where a single API supports desktop 419 and mobile devices, but the functionality is retained. 420 * attr:category - optional. A string which indicates that this type 421 contains a more complex structured definition. At present the only 422 accepted categories are `basetype`, `bitmask`, `define`, `enum`, 423 `funcpointer`, `group`, `handle`, `include`, `struct`, and `union`, 424 as described below. 425 * attr:comment - optional. Arbitrary string (unused). 426 * attr:parent only applicable if category is `handle`. Notes another 427 type with the `handle` category that acts as a parent object for 428 this type. 429 * attr:returnedonly only applicable if category is `struct` or 430 `union`. Notes that this struct/union is going to be filled in by 431 the API, rather than an application filling it out and passing it to 432 the API. 433 * attr:structextends only applicable if category is `struct` or `union`. 434 This is a comma-separated list of structures whose `pNext` can include 435 this type. 436 This should usually only list the top-level structure that is 437 extended, for all possible chained structures - the chained structures 438 themselves should have their `pNext` tagged with attr:noautovalidity. 439 This will generate a validity statement on the top level structure 440 that validates the entire chain in one go, rather than each chained 441 structure repeating the list of valid structs. 442 443== Contents of tag:type tags 444 445The valid contents depend on the attr:category attribute. 446 447=== Enumerated types - attr:category `"enum"` 448 449If the attr:category tag has the value `enum`, the type is a C 450enumeration. The body of the tag is ignored in this case. The value of 451the attr:name attribute must be provided and must match the attr:name 452attribute of a <<tag-enums,tag:enums>> tag. The enumerant values defined 453within the tag:enums tag are used to generate a C `enum` type 454declaration. 455 456=== Structure types - attr:category `"struct"` or `"union"` 457 458If the attr:category tag has the values `struct` or `union`, the type is a C 459structure or union, respectively. In this case, the attr:name attribute must 460be provided, and the contents of the tag:type tag are a series of tag:member 461tags defining the members of the aggregate type, in order, interleaved with 462any number of tag:comment tags. 463 464==== Structure member (tag:member) tags 465 466The tag:member tag defines the type and name of a structure or union 467member. 468 469==== Attributes of tag:member tags 470 471 * attr:values - only valid on the `sType` member of a struct. This is a 472 comma-separated list of enumerant values that are valid for the 473 structure type; usually there is only a single value. 474 * attr:len - if the member is an array, len may be one or more of the 475 following things, separated by commas (one for each array 476 indirection): another member of that struct; `"null-terminated"` for 477 a string; `"1"` to indicate it is just a pointer (used for nested 478 pointers); or an equation in math markup for incorporation in the 479 specification (a LaTeX math expression delimited by `latexmath:[` and 480 `]`. 481 The only variables in the equation should be the names of members of the 482 structure. 483 * attr:altlen - if the attr:len attribute is specified, and 484 contains a `latexmath:` equation, this attribute should 485 be specified with an equivalent equation using only C builtin operators, 486 C math library function names, and variables as allowed for attr:len. 487 It must be a valid C99 expression whose result is equal to attr:len for 488 all possible inputs. 489 It is a comma separated list that has size equal to only the `latexmath` 490 item count in attr:len list. 491 This attribute is intended to support consumers of the XML who need to 492 generate validation code from the allowed length. 493 * attr:externsync - denotes that the member should be externally 494 synchronized when accessed by Vulkan 495 * attr:optional - a value of `"true"` or `"false"` determines whether this 496 member can be omitted by providing `NULL` (for pointers), 497 `VK_NULL_HANDLE` (for handles), 0 (for bitmasks), or 0 for values 498 that are the size of an array in the same structure. If the member 499 is a pointer to one of those types, multiple values may be provided, 500 separated by commas - one for each pointer indirection. 501 * attr:noautovalidity - prevents automatic validity language being 502 generated for the tagged item. Only suppresses item-specific 503 validity - parenting issues etc. are still captured. 504 It must also be used for structures that have no implicit validity when 505 such structure has explicit validity. 506 507==== Contents of tag:member tags 508 509The text elements of a tag:member tag, with all other tags removed, 510is a legal C declaration of a struct or union member. In addition it may 511contain several semantic tags: 512 513 * The tag:type tag is optional. It contains text which is a valid type 514 name found in another tag:type tag, and indicates that this type 515 must be previously defined for the definition of the command to 516 succeed. Builtin C types should not be wrapped in tag:type tags. 517 * The tag:name tag is required, and contains the struct/union member 518 name being described. 519 * The tag:enum tag is optional. It contains text which is a valid 520 enumerant name found in another tag:type tag, and indicates that this 521 enumerant must be previously defined for the definition of the command 522 to succeed. Typically this is used to semantically tag static array 523 lengths. 524 * The tag:comment tag is optional. It contains an arbitrary string 525 (unused). 526 527 528=== All other types 529 530If the attr:category attribute is one of `basetype`, `bitmask`, 531`define`, `funcpointer`, `group`, `handle` or 532`include`, or is not specified, tag:type contains text which is legal 533C code for a type declaration. It may also contain embedded tags: 534 535 * tag:type - nested type tags contain other type names which are 536 required by the definition of this type. 537 * tag:apientry/ - insert a platform calling convention macro here 538 during header generation, used mostly for function pointer types. 539 * tag:name - contains the name of this type (if not defined in the tag 540 attributes). 541 542There is no restriction on which sorts of definitions may be made in a given 543category, although the contents of tags with attr:category `enum`, 544`struct` or `union` are interpreted specially as described above. 545 546However, when generating the header, types within each category are grouped 547together, and categories are generated in the order given by the following 548list. Therefore, types in a category should correspond to the intended 549purpose given for that category. If this recommendation is not followed, it 550is possible that the resulting header file will not compile due to 551out-of-order type dependencies. The intended purpose of each category is: 552 553 * `include` (`#include`) directives) 554 * `define` (macro `#define` directives) 555 * `basetype` (scalar typedefs, such as the definition of `VkFlags`) 556 * `handle` (invocations of macros defining scalar types such as 557 `VkInstance`) 558 * `enum` (enumeration types and `#define` for constant values) 559 * `group` (currently unused) 560 * `bitmask` (enumeration types whose members are bitmasks) 561 * `funcpointer` (function pointer typedefs) 562 * `struct` and `union` together (struct and union types) 563 564 565[[tag-types:example]] 566== Example of a tag:types tag 567 568[source,xml] 569-------------------------------------- 570<types> 571 <type name="stddef">#include <stddef.h></type> 572 <type requires="stddef">typedef ptrdiff_t <name>VKlongint</name>;</type> 573 <type name="VkEnum" category="enum"/> 574 <type category="struct" name="VkStruct"> 575 <member><type>VkEnum</type> <name>srcEnum</name></member> 576 <member><type>VkEnum</type> <name>dstEnum</name></member> 577 </type> 578</types> 579 580<enums name="VkEnum" type="enum"> 581 <enum value="0" name="VK_ENUM_ZERO"/> 582 <enum value="42" name="VK_ENUM_FORTY_TWO"/> 583</enums> 584-------------------------------------- 585 586The `VkStruct` type is defined to require the types `VkEnum` and 587`VKlongint` as well. If `VkStruct` is in turn required by a command 588or another type during header generation, it will result in the following 589declarations: 590 591[source,c] 592-------------------------------------- 593#include <stddef.h> 594typedef ptrdiff_t VKlongint. 595 596typedef enum { 597 VK_ENUM_ZERO = 0, 598 VK_ENUM_FORTY_TWO = 42 599} VkEnum; 600 601typedef struct { 602 VkEnum dstEnum; 603 VkLongint dstVal; 604} VkStruct; 605-------------------------------------- 606 607Note that the angle brackets around `stddef.h` are represented as XML 608entities in the registry. This could also be done using a CDATA block but 609unless there are many characters requiring special representation in XML, 610using entities is preferred. 611 612 613[[tag-enums]] 614= Enumerant Blocks (tag:enums tag) 615 616The tag:enums tags contain individual tag:enum tags describing each of 617the token names used in the API. In some cases these correspond to a C 618`enum`, and in some cases they are simply compile time constants (e.g. 619`#define`). 620 621[NOTE] 622.Note 623==== 624It would make more sense to call these `const` or `define` tags. 625This is a historical hangover from the OpenGL XML format which this schema 626was based on. 627==== 628 629 630== Attributes of tag:enums tags 631 632 * attr:name - optional. String naming the C `enum` type whose members are 633 defined by this enum group. If present, this attribute should match the 634 attr:name attribute of a corresponding tag:type tag. 635 * attr:type - optional. String describing the data type of the values of 636 this group of enums. At present the only accepted categories are `enum` 637 and `bitmask`, as described below. 638 * attr:start, attr:end - optional. Integers defining the start and end of 639 a reserved range of enumerants for a particular vendor or purpose. 640 attr:start must be less than or equal to attr:end. These fields define 641 formal enumerant allocations, and are made by the Khronos Registrar on 642 request from implementers following the enum allocation policy. 643 * attr:vendor - optional. String describing the vendor or purpose to whom 644 a reserved range of enumerants is allocated. 645 * attr:comment - optional. Arbitrary string (unused). 646 647== Contents of tag:enums tags 648 649Each tag:enums block contains zero or more tag:enum, tag:unused, and 650tag:comment tags, in arbitrary order (although they are typically ordered by 651sorting on enumerant values, to improve human readability). 652 653== Example of tag:enums tags 654 655<<tag-types:example,An example>> showing a tag with attribute 656attr:type`="enum"` is given above. The following example is for 657non-enumerated tokens. 658 659[source,xml] 660-------------------------------------- 661<enums> 662 <enum value="256" name="VK_MAX_EXTENSION_NAME"/> 663 <enum value="MAX_FLOAT" name="VK_LOD_CLAMP_NONE"/> 664</enums> 665-------------------------------------- 666 667When processed into a C header, and assuming all these tokens were 668required, this results in 669 670[source,c] 671-------------------------------------- 672#define VK_MAX_EXTENSION_NAME 256 673#define VK_LOD_CLAMP_NONE MAX_FLOAT 674-------------------------------------- 675 676 677[[tag-enum]] 678= Enumerants (tag:enum tag) 679 680Each tag:enum tag defines a single Vulkan (or other API) token. 681 682== Attributes of tag:enum tags 683 684 * attr:value or attr:bitpos - exactly one of these is allowed and 685 required. attr:value is an enumerant value in the form of a legal C 686 constant (usually a literal decimal or hexadecimal integer, though 687 arbitrary strings are allowed). attr:bitpos is a literal integer bit 688 position in a bitmask. 689 * attr:name - required. Enumerant name, a legal C preprocessor token 690 name. 691 * attr:api - optional. An API name which specializes this definition 692 of the named enum, so that different APIs may have different values 693 for the same token. May be used to address a subtle 694 incompatibilities. 695 * attr:type - optional. Used only when attr:value is specified. C 696 suffix for the value to force it to a specific type. Currently only 697 `u` and `ull` are used, for `unsigned` 32- and 64-bit integer 698 values, respectively. Separated from attr:value since this eases 699 parsing and sorting of values, and rarely used. 700 * attr:alias - optional. Name of another enumerant this is an alias 701 of, used where token names have been changed as a result of profile 702 changes or for consistency purposes. An enumerant alias is simply a 703 different attr:name for the exact same attr:value or attr:bitpos. 704 705== Contents of tag:enum tags 706 707tag:enum tags have no allowed contents. All information is contained 708in the attributes. 709 710 711[[tag-unused]] 712= Unused Enumerants (tag:unused tag) 713 714Each tag:unused tag defines a range of enumerants which is allocated, but 715not yet assigned to specific enums. This just tracks the unused values for 716the Registrar's use, and is not used for header generation. 717 718[NOTE] 719.Note 720==== 721tag:unused tags could be generated and inserted automatically, which would 722be a good way to avoid the attributes becoming out of date. However, they 723are rarely used in the Vulkan XML schema, unlike the OpenGL XML schema it 724was based on. 725==== 726 727== Attributes of tag:unused tags 728 729 * attr:start - required, attr:end - optional. Integers defining the 730 start and end of an unused range of enumerants. attr:start must be 731 {leq} attr:end. If attr:end is not present, then attr:start defines a 732 single unused enumerant. This range should not exceed the range 733 reserved by the surrounding tag:enums tag. 734 * attr:vendor - optional. String describing the vendor or purposes to 735 whom a reserved range of enumerants is allocated. Usually identical 736 to the attr:vendor attribute of the surrounding attr:enums block. 737 * attr:comment - optional. Arbitrary string (unused). 738 739== Contents of tag:unused tags 740 741None. 742 743 744[[tag-commands]] 745= Command Blocks (tag:commands tag) 746 747The tag:commands tag contains definitions of each of the functions 748(commands) used in the API. 749 750== Attributes of tag:commands tags 751 752 * attr:comment - optional. Arbitrary string (unused). 753 754== Contents of tag:commands tags 755 756Each tag:commands block contains zero or more tag:command tags, in 757arbitrary order (although they are typically ordered by sorting on the 758command name, to improve human readability). 759 760 761[[tag-command]] 762= Commands (tag:command tag) 763 764The tag:command tag contains a structured definition of a single API 765command (function). 766 767== Attributes of tag:command tags 768 769There are two ways to define a command. The first uses a set of attributes 770to the tag:command tag defining properties of the command used for 771constructing automatic validation rules, and the contents of the tag:command 772tag define the name, signature, and parameters of the command. In this case 773the allowed attributes include: 774 775 * attr:queues - optional. A string identifying the command queues this 776 command can be placed on. The format of the string is one or more of 777 the terms `"compute"`, `"transfer"`, and `"graphics"`, with multiple 778 terms separated by commas (`","`). 779 * attr:successcodes - optional. A string describing possible 780 successful return codes from the command, as a comma-separated list 781 of Vulkan result code names. 782 * attr:errorcodes - optional. A string describing possible error 783 return codes from the command, as a comma-separated list of Vulkan 784 result code names. 785 * attr:renderpass - optional. A string identifying whether the command 786 can be issued only inside a render pass (`"inside"`), only outside a 787 render pass (`"outside"`), or both (`"both"`). 788 * attr:cmdbufferlevel - optional. A string identifying the command 789 buffer levels that this command can be called by. The format of the 790 string is one or more of the terms `"primary"` and `"secondary"`, 791 with multiple terms separated by commas (`","`). 792 * attr:pipeline - optional. A string identifying the pipeline type 793 that this command uses when executed. The format of the string is one of 794 the terms `"compute"`, `"transfer"`, or `"graphics"`. 795 * attr:comment - optional. Arbitrary string (unused). 796 797The second way of defining a command is as an alias of another command. For 798example when an extension is promoted from extension to core status, the 799commands defined by that extensions become aliases of the corresponding new 800core commands. In this case, only two attributes are allowed: 801 802 * attr:name - required. A string naming the command defined by the tag. 803 * attr:alias - required. A string naming the command that attr:name is an 804 alias of. The string must be the same as the attr:name value of another 805 tag:command defining another command. 806 807== Contents of tag:command tags 808 809 * tag:proto is required and must be the first element. It is a tag 810 defining the C function prototype of a command as described below, 811 up to the function name and return type but not including function 812 parameters. 813 * tag:param elements for each command parameter follow, defining its 814 name and type, as described below. If a command takes no arguments, 815 it has no tag:param tags. 816 817Following these elements, the remaining elements in a tag:command 818tag are optional and may be in any order: 819 820 * tag:alias - optional. Has no attributes and contains a string which 821 is the name of another command this command is an alias of, used 822 when promoting a function from vendor to Khronos extension or 823 Khronos extension to core API status. A command alias describes the 824 case where there are two function names which resolve to the _same_ 825 entry point in the underlying layer stack. 826 * tag:description - optional. Unused text. 827 * tag:implicitexternsyncparams - optional. Contains a list of tag:param 828 tags, each containing asciidoc source text describing an object which is 829 not a parameter of the command but is related to one, and which also 830 <<tag-command:param:attr,requires external synchronization>>. The text 831 is intended to be incorporated into the API specification. 832 833 834[[tag-command:proto]] 835== Command prototype (tag:proto tags) 836 837The tag:proto tag defines the return type and name of a command. 838 839=== Attributes of tag:proto tags 840 841None. 842 843// attr:group - group name, an arbitrary string. 844// 845// If the group name is defined, it may be interpreted as described in 846// <<tag-group:meaning>>. 847 848=== Contents of tag:proto tags 849 850The text elements of a tag:proto tag, with all other tags removed, is 851legal C code describing the return type and name of a command. In addition 852to text, it may contain two semantic tags: 853 854 * The tag:type tag is optional, and contains text which is a valid 855 type name found in a tag:type tag. It indicates that this type must 856 be previously defined for the definition of the command to succeed. 857 Builtin C types, and any derived types which are expected to be 858 found in other header files, should not be wrapped in tag:type tags. 859 * The tag:name tag is required, and contains the command name being 860 described. 861 862 863[[tag-command:param]] 864== Command parameter (tag:param tags) 865 866The tag:param tag defines the type and name of a parameter. Its contents 867are very similar to the tag:member tag used to define struct and union 868members. 869 870 871[[tag-command:param:attr]] 872=== Attributes of tag:param tags 873 874 * attr:len - if the param is an array, len may be one or more of the 875 following things, separated by commas (one for each array 876 indirection): another param of that command; `"null-terminated"` for 877 a string; `"1"` to indicate it is just a pointer (used for nested 878 pointers); or an equation in math markup for incorporation in the 879 specification (a LaTeX math expression delimited by `latexmath:[` and 880 `]`. 881 The only variables in the equation should be the names of this or other 882 parameters. 883 * attr:altlen - if the attr:len attribute is specified, and 884 contains a `latexmath:` equation, this attribute should 885 be specified with an equivalent equation using only C builtin operators, 886 C math library function names, and variables as allowed for attr:len. 887 It must be a valid C99 expression whose result is equal to attr:len for 888 all possible inputs. 889 It is a comma separated list that has size equal to only the `latexmath` 890 item count in attr:len list. 891 This attribute is intended to support consumers of the XML who need to 892 generate validation code from the allowed length. 893 * attr:optional - a value of `"true"` or `"false"` determines whether this 894 member can be omitted by providing `NULL` (for pointers), 895 `VK_NULL_HANDLE` (for handles), 0 (for bitmasks), or 0 for values 896 that are the size of an array in the same command. If the member is 897 a pointer to one of those types, multiple values may be provided, 898 separated by commas - one for each pointer indirection. 899 * attr:noautovalidity - prevents automatic validity language being 900 generated for the tagged item. Only suppresses item-specific 901 validity - parenting issues etc. are still captured. 902 * attr:externsync - optional. A value of `"true"` indicates that this 903 parameter (e.g. the object a handle refers to, or the contents of an 904 array a pointer refers to) is modified by the command, and is not 905 protected against modification in multiple app threads. If only certain 906 members of an object or elements of an array are modified, multiple 907 strings may be provided, separated by commas. Each string describes a 908 member which is modified. For example, the `vkQueueSubmit` command 909 includes attr:externsync attributes for the `pSubmits` array indicating 910 that only specific members of each element of the array are modified: 911+ 912-- 913[source,xml] 914-------------------------------------- 915<param len="submitCount" externsync="pSubmits[].pWaitSemaphores[],pSubmits[].pSignalSemaphores[]">const <type>VkSubmitInfo</type>* <name>pSubmits</name></param> 916-------------------------------------- 917 918Parameters which do not have an attr:externsync attribute are assumed to not 919require external synchronization. 920-- 921 922=== Contents of tag:param tags 923 924The text elements of a tag:param tag, with all other tags removed, is 925legal C code describing the type and name of a function parameter. In 926addition it may contain two semantic tags: 927 928 * The tag:type tag is optional, and contains text which is a valid 929 type name found in tag:type tag, and indicates that this type must 930 be previously defined for the definition of the command to succeed. 931 Builtin C types, and any derived types which are expected to be 932 found in other header files, should not be wrapped in tag:type tags. 933 * The tag:name tag is required, and contains the parameter name being 934 described. 935 936== Example of a tag:commands tag 937 938[source,xml] 939-------------------------------------- 940<commands> 941 <command> 942 <proto><type>VkResult</type> <name>vkCreateInstance</name></proto> 943 <param>const <type>VkInstanceCreateInfo</type>* <name>pCreateInfo</name></param> 944 <param><type>VkInstance</type>* <name>pInstance</name></param> 945 </command> 946</commands> 947-------------------------------------- 948 949When processed into a C header, this results in 950 951[source,c] 952-------------------------------------- 953VkResult vkCreateInstance( 954 const VkInstanceCreateInfo* pCreateInfo, 955 VkInstance* pInstance); 956-------------------------------------- 957 958 959[[tag-feature]] 960= API Features and Versions (tag:feature tag) 961 962API features are described in individual tag:feature tags. A feature is 963the set of interfaces (enumerants and commands) defined by a particular API 964and version, such as Vulkan 1.0, and includes all profiles of that API and 965version. 966 967== Attributes of tag:feature tags 968 969 * attr:api - required. <<schema:apiname,API name>> this feature is for, 970 such as `vk`. 971 * attr:name - required. Version name, used as the C preprocessor token 972 under which the version's interfaces are protected against multiple 973 inclusion. Example: `"VK_VERSION_1_0"`. 974 * attr:number - required. Feature version number, usually a string 975 interpreted as `majorNumber.minorNumber`. Example: `4.2`. 976 * attr:protect - optional. An additional preprocessor token used to 977 protect a feature definition. Usually another feature or extension 978 attr:name. Rarely used, for odd circumstances where the definition 979 of a feature or extension requires another to be defined first. 980 * attr:comment - optional. Arbitrary string (unused). 981 982[NOTE] 983.Note 984==== 985The attr:name attribute used for Vulkan core versions, such as 986`"VK_VERSION_1_0"`, is not an API construct. 987It is used only as a preprocessor guard in the headers, and an asciidoctor 988conditional in the specification sources. 989The similar `"VK_API_VERSION_1_0"` symbols are part of the API and their 990values are packed integers containing Vulkan core version numbers. 991==== 992 993== Contents of tag:feature tags 994 995Zero or more <<tag-required,tag:require and tag:remove tags>>, in arbitrary 996order. Each tag describes a set of interfaces that is respectively required 997for, or removed from, this feature, as described below. 998 999== Example of a tag:feature tag 1000 1001[source,xml] 1002-------------------------------------- 1003<feature api="vulkan" name="VK_VERSION_1_0" number="1.0"> 1004 <require comment="Header boilerplate"> 1005 <type name="vk_platform"/> 1006 </require> 1007 <require comment="API constants"> 1008 <enum name="VK_MAX_PHYSICAL_DEVICE_NAME"/> 1009 <enum name="VK_LOD_CLAMP_NONE"/> 1010 </require> 1011 <require comment="Device initialization"> 1012 <command name="vkCreateInstance"/> 1013 </require> 1014</feature> 1015-------------------------------------- 1016 1017When processed into a C header for Vulkan, this results in: 1018 1019[source,c] 1020-------------------------------------- 1021#ifndef VK_VERSION_1_0 1022#define VK_VERSION_1_0 1 1023#define VK_MAX_EXTENSION_NAME 256 1024#define VK_LOD_CLAMP_NONE MAX_FLOAT 1025typedef VkResult (VKAPI_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance); 1026#ifndef VK_NO_PROTOTYPES 1027VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance( 1028 const VkInstanceCreateInfo* pCreateInfo, 1029 VkInstance* pInstance); 1030#endif 1031#endif /* VK_VERSION_1_0 */ 1032-------------------------------------- 1033 1034 1035[[tag-extensions]] 1036= Extension Blocks (tag:extensions tag) 1037 1038The tag:extensions tag contains definitions of each of the extenions 1039which are defined for the API. 1040 1041== Attributes of tag:extensions tags 1042 1043 * attr:comment - optional. Arbitrary string (unused). 1044 1045== Contents of tag:extensions tags 1046 1047Each tag:extensions block contains zero or more tag:extension tags, 1048each describing an API extension, in arbitrary order (although they are 1049typically ordered by sorting on the extension name, to improve human 1050readability). 1051 1052 1053[[tag-extension]] 1054= API Extensions (tag:extension tag) 1055 1056API extensions are described in individual tag:extension tags. An 1057extension is the set of interfaces defined by a particular API extension 1058specification, such as `ARB_multitexture`. tag:extension is 1059similar to tag:feature, but instead of having attr:version and 1060attr:profile attributes, instead has a attr:supported attribute, 1061which describes the set of API names which the extension can potentially 1062be implemented against. 1063 1064== Attributes of tag:extension tags 1065 1066 * attr:name - required. Extension name, following the conventions in 1067 the Vulkan Specification. Example: `name="VK_VERSION_1_0"`. 1068 * attr:number - required. A decimal number which is the registered, 1069 unique extension number for attr:name. 1070 * attr:author - optional. The author name, such as a full company 1071 name. If not present, this can be taken from the corresponding 1072 tag:tag attribute. However, `EXT` and other multi-vendor extensions 1073 may not have a well-defined author or contact in the tag. This attribute 1074 is not used in processing the XML. It is just metadata, mostly used to 1075 track the original author of an extension (which may have since been 1076 promoted to use a different author ID). 1077 * attr:contact - optional. The contact who registered or is currently 1078 responsible for extensions and layers using the tag, including 1079 sufficient contact information to reach the contact such as individual 1080 name together with Github username (`@username`), Khronos internal 1081 Gitlab username (`gitlab:@username`) if no public Github contact is 1082 avaliable, or other contact information. If not present, this can be 1083 taken from the corresponding tag:tag attribute just like attr:author. 1084 * attr:type - required if the attr:supported attribute is not 1085 `'disabled'`. Must be either `'device'` or `'instance'`, if present. 1086 * attr:requires - optional. Comma-separated list of extension names this 1087 extension requires to be supported. 1088 * attr:requiresCore - optional. Core version of Vulkan required by the 1089 extension, e.g. "1.1". Defaults to "1.0". 1090 * attr:protect - optional. An additional preprocessor token used to 1091 protect an extension definition. Usually another feature or 1092 extension attr:name. Rarely used, for odd circumstances where the 1093 definition of an extension requires another extension or a header 1094 file to be defined first. 1095 * attr:platform - optional. Indicates that the extension is specific to 1096 the platform identified by the attribute value, and should be emitted 1097 conditional on that platform being available, in a platform-specific 1098 header, etc. The attribute value must be the same as one of the 1099 tag:platform tag:name attribute values. 1100 * attr:supported - required. A regular expression with an implicit `^` and 1101 `$` bracketing it, which should match the attr:api tag of a set of 1102 tag:feature tags. When the extension tag is just reserving an extension 1103 number, and no interfaces are yet defined, use `supported="disabled"` to 1104 indicate this extension should never be processed. 1105 * attr:promotedto - optional. A Vulkan version or a name of an extension 1106 that this extension was _promoted_ to; e.g. 'VK_VERSION_1_1', or 1107 'VK_KHR_draw_indirect_county'. 1108 * attr:deprecatedby - optional. A Vulkan version or a name of an extension 1109 that _deprecates_ this extension. It may be an empty string. e.g. 1110 'VK_VERSION_1_1', or 'VK_EXT_debug_utils', or ''. 1111 * attr:obsoletedby - optional. A Vulkan version or a name of an extension 1112 that _obsoletes_ this extension. It may be an empty string. e.g. 1113 'VK_VERSION_1_1', or 'VK_KHR_maintenance1', or ''. 1114 * attr:comment - optional. Arbitrary string (unused). 1115 1116 1117[NOTE] 1118.Note 1119==== 1120The attr:requires attribute is used to specify other extensions that *must* 1121be enabled for an extension to be enabled. 1122 1123In some cases, an extension may include functionality which is only defined 1124*if* another extension is enabled. Such functionality should be specified 1125within a tag:require, using the attr:extension attribute to specify that 1126extension. 1127==== 1128 1129== Contents of tag:extension tags 1130 1131Zero or more <<tag-required,tag:require and tag:remove tags>>, in arbitrary 1132order. Each tag describes a set of interfaces that is respectively required 1133for, or removed from, this extension, as described below. 1134 1135== Example of an tag:extensions tag 1136 1137[source,xml] 1138-------------------------------------- 1139<extension name="VK_KHR_display_swapchain" number="4" supported="vulkan"> 1140 <require> 1141 <enum value="9" name="VK_KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION"/> 1142 <enum value="4" name="VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NUMBER"/> 1143 <enum value=""VK_KHR_display_swapchain"" 1144 name="VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME"/> 1145 <type name="VkDisplayPresentInfoKHR"/> 1146 <command name="vkCreateSharedSwapchainsKHR"/> 1147 </require> 1148</extension> 1149-------------------------------------- 1150 1151The attr:supported attribute says that the extension is defined for the 1152default profile (`vulkan`). When processed into a C header for the 1153`vulkan` profile, this results in header contents something like 1154(assuming corresponding definitions of the specified tag:type and 1155tag:command elsewhere in the XML): 1156 1157[source,c] 1158-------------------------------------- 1159#define VK_KHR_display_swapchain 1 1160#define VK_KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION 9 1161#define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NUMBER 4 1162#define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME "VK_KHR_display_swapchain" 1163 1164typedef struct VkDisplayPresentInfoKHR { 1165 VkStructureType sType; 1166 const void* pNext; 1167 VkRect2D srcRect; 1168 VkRect2D dstRect; 1169 VkBool32 persistent; 1170} VkDisplayPresentInfoKHR; 1171 1172typedef VkResult (VKAPI_PTR *PFN_vkCreateSharedSwapchainsKHR)( 1173 VkDevice device, uint32_t swapchainCount, 1174 const VkSwapchainCreateInfoKHR* pCreateInfos, 1175 const VkAllocationCallbacks* pAllocator, 1176 VkSwapchainKHR* pSwapchains); 1177 1178#ifndef VK_NO_PROTOTYPES 1179VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR( 1180 VkDevice device, 1181 uint32_t swapchainCount, 1182 const VkSwapchainCreateInfoKHR* pCreateInfos, 1183 const VkAllocationCallbacks* pAllocator, 1184 VkSwapchainKHR* pSwapchains); 1185#endif 1186-------------------------------------- 1187 1188 1189[[tag-required]] 1190= Required and Removed Interfaces (tag:require and tag:remove tags) 1191 1192A tag:require block defines a set of interfaces (types, enumerants and 1193commands) 'required' by a tag:feature 1194or tag:extension. A tag:remove block defines a set of interfaces 1195'removed' by a tag:feature. This is primarily for 1196future profiles of an API which may choose to deprecate and/or remove 1197some interfaces. 1198Extensions should never remove interfaces, although this 1199usage is allowed by the schema). Except for the tag name and behavior, 1200the contents of tag:require and tag:remove tags are identical. 1201 1202== Attributes of tag:require and tag:remove tags 1203 1204 * attr:profile - optional. String name of an API profile. Interfaces 1205 in the tag are only required (or removed) if the specified profile 1206 is being generated. If not specified, interfaces are required (or 1207 removed) for all API profiles. 1208 * attr:comment - optional. Arbitrary string (unused). 1209 * attr:api - optional. An <<schema:apiname,API name>>. 1210 Interfaces in the tag are only required (or removed) if the 1211 specified API is being generated. If not specified, interfaces are 1212 required (or removed) for all APIs. 1213 1214 1215[NOTE] 1216.Note 1217==== 1218The attr:api attribute is only supported inside tag:extension tags, 1219since tag:feature tags already define a specific API. 1220==== 1221 1222== Attributes of tag:require tags 1223 1224These attribues are allowed only for a tag:require tag. 1225 1226 * attr:extension - optional, and only for tag:require tags. String 1227 containing an API extension name. Interfaces in the tag are only 1228 required if the string matches the attr:name of an tag:extension tag, 1229 and that extension is enabled. 1230 * attr:feature - optional, and only for tag:require tags. String 1231 containing an API feature name. Interfaces in the tag are only required 1232 if the string matches the attr:name of a tag:feature tag, and that 1233 feature is enabled. 1234 1235[NOTE] 1236.Note 1237==== 1238The attr:extension attribute currently does not affect output generators in 1239any way, and is simply metadata. This will be addressed as we better define 1240different types of dependencies between extensions. 1241==== 1242 1243== Contents of tag:require and tag:remove tags 1244 1245Zero or more of the following tags, in any order: 1246 1247=== Comment Tags 1248 1249<<tag-comment, tag:comment>> (as described above). 1250 1251=== Command Tags 1252 1253tag:command specifies an required (or removed) command defined 1254in a tag:commands block. The tag has no content, but contains 1255attributes: 1256 1257 * attr:name - required. Name of the command. 1258 * attr:comment - optional. Arbitrary string (unused). 1259 1260=== Enum tags 1261 1262tag:enum specifies an required (or removed) enumerant defined in a 1263tag:enums block. All forms of this tag support the following attributes: 1264 1265 * attr:name - required. Name of the enumerant. 1266 * attr:comment - optional. Arbitrary string (unused). 1267 * attr:api - optional. An API name which specializes this definition of 1268 the enumerant attr:name, so that different APIs may have different 1269 values for the same token. May be used to address subtle 1270 incompatibilities. 1271 1272There are two forms of tag:enum tags: 1273 1274_Reference enums_ simply pull in the definition of an enumerant given in 1275a separate tag:enums block. Reference enums are the most common usage, 1276and no attributes other than attr:name and attr:comment are supported 1277for them. 1278 1279_Extension enums_ define the value of an enumerant inline in an tag:feature 1280or tag:extensions block. Typically these are used to add additional values 1281specified by an extension or core feature to an existing enumerated type. 1282There are a variety of attributes which are used to specify the value of the 1283enumerant, although not all combinations of attributes are either meaningful 1284or supported. Possible attributes are described first, followed by the 1285allowed combinations: 1286 1287 * attr:value and attr:type - define a constant value in the same fashion 1288 as an tag:enum tag in an <<tag-enum,tag:enums>> block. 1289 * attr:bitpos - define a constant bitmask value in the same fashion as an 1290 <<tag-enum,tag:enum>> tag in an tag:enums block. 1291 * attr:extends - the name of a separately defined enumerated type (e.g. a 1292 tag:type tag with attr:category``="enum"``) to which the extension 1293 enumerant is added. If not present, the enumerant is treated as a global 1294 constant value. 1295 * attr:extnumber - an extension number. The extension number in turn 1296 specifies the starting value of a block (range) of values reserved for 1297 enumerants defined by or associated with the corresponding tag:extension 1298 tag with the same attr:number. This is used when an extension or core 1299 feature needs to extend an enumerated type in a block defined by a 1300 different extension. 1301 * Attribute attr:offset - the offset within an extension block. If 1302 attr:extnumber is not present, the extension number defining that block 1303 is given by the attr:number attribute of the surrounding tag:extension 1304 tag. The actual numeric value of the enumerant is computed as defined in 1305 the "`Layers and Extensions`" appendix of the Vulkan Specification. 1306 * Attribute attr:dir - if present, the calculated enumerant value will be 1307 negative, instead of positive. Negative enumerant values are normally 1308 used only for Vulkan error codes. The attribute value must be specified 1309 as `dir="-"`. 1310 * attr:alias - the name of another enumerant this is an alias of. An 1311 enumerant alias is simply a different name for the same enumerant value. 1312 This is typically used when promoting an enumerant defined by an 1313 extension to a new core version of the API. The old extension enumerant 1314 is still defined, but as an alias of the new core enumerant. It may also 1315 be used when token names have been changed as a result of profile 1316 changes, or for consistency purposes. 1317 * attr:api - an API name which specializes this definition of the named 1318 enum, so that different APIs may have different values for the same 1319 token. May be used to address subtle incompatibilities. 1320 1321 1322.Valid Combinations of attr:enum Attributes 1323|==== 1324| attr:value | attr:bitpos | attr:alias | attr:offset | attr:extnumber | attr:dir | attr:extends | Description 1325| {yes} | {no} | {no} | {no} | {no} | {no} | {opt}^2^ | Numeric value 1326| {no} | {yes} | {no} | {no} | {no} | {no} | {opt}^2^ | Bitmask value 1327| {no} | {no} | {yes} | {no} | {no} | {no} | {opt}^2^ | Alias of another enumerant 1328| {no} | {no} | {no} | {yes} | {opt}^1^ | {opt} | {yes} | Value added to an enumeration 1329| {no} | {no} | {no} | {yes} | {opt}^1^ | {opt} | {yes} | Value added to an enumeration 1330|==== 1331 1332[1]: If attr:extnumber is not present, the tag:enum tag may only be within a 1333tag:extension. Otherwise, the tag:enum tag may also be within a tag:feature. 1334 1335[2]: If attr:extends is not present, the enumerant value is a global 1336constant. Otherwise, the value is added to the specified enumeration. 1337 1338Examples of <<tag-required-examples,various types of extension enumerants>> 1339are given below. 1340 1341 1342=== Type tags 1343 1344tag:type specifies a required (or removed) type defined in a 1345tag:types block. Most types are picked up implicitly by using the 1346tag:type tags of commands, but in a few cases, additional types need 1347to be specified explicitly. It is unlikely that a type would ever be 1348removed, although this usage is allowed by the schema. The tag has no 1349content, but contains elements: 1350 1351 * attr:name - required. Name of the type. 1352 * attr:comment - optional. Arbitrary string (unused). 1353 1354 1355[[tag-required-examples]] 1356== Examples of Extension Enumerants 1357 1358Examples of some of the supported extension enumerant tag:enum tags are 1359given below. 1360 1361[source,xml] 1362-------------------------------------- 1363<extensions> 1364 <extension name="VK_KHR_test_extension" number="1" supported="vulkan"> 1365 <require> 1366 <enum value="42" name="VK_KHR_theanswer"/> 1367 <enum bitpos="29" name="VK_KHR_bitmask"/> 1368 <enum offset="0" dir="-" extends="VkResult" 1369 name="VK_ERROR_SURFACE_LOST_KHR"/> 1370 <enum offset="1" extends="VkResult" 1371 name="VK_SUBOPTIMAL_KHR"/> 1372 <enum bitpos="31" extends="VkResult" 1373 name="VK_KHR_EXTENSION_BIT"/> 1374 </require> 1375 </extension> 1376</extensions> 1377-------------------------------------- 1378 1379The corresponding header file will include definitions like this: 1380 1381[source,c] 1382-------------------------------------- 1383typedef enum VkResult { 1384 <previously defined VkResult enumerant values}, 1385 VK_ERROR_SURFACE_LOST_KHR = -1000000000, 1386 VK_SUBOPTIMAL_KHR = 1000000001, 1387 VK_KHR_EXTENSION_BIT = 0x80000000, 1388}; 1389 1390#define VK_KHR_test_extension 1 1391#define VK_KHR_theanswer 42 1392#define VK_KHR_bitmask 0x20000000 1393-------------------------------------- 1394 1395 1396[[examples]] 1397= Examples / FAQ / How Do I? 1398 1399For people new to the Registry, it will not be immediately obvious how 1400to make changes. This section includes some tips and examples that will 1401help you make changes to the Vulkan headers by changing the Registry XML 1402description. 1403 1404First, follow the steps described to <<starting,get the Vulkan Github 1405repository>> containing the registry and assemble the tools necessary to 1406work with the XML registry. Once you are able to regenerate the Vulkan 1407headers from `vk.xml`, you can start making changes. 1408 1409 1410== General Strategy 1411 1412If you are _adding_ to the API, perform the following steps to _create_ 1413the description of that API element: 1414 1415 * For each type, enum group, compile time constant, and command being 1416 added, create appropriate new tag:type, tag:enums, tag:enum, or 1417 tag:command tags defining the interface in question. 1418 * Make sure that all added types and commands appropriately tag their 1419 dependencies on other types by adding nested tag:type tags. 1420 * Make sure that each new tag defines the name of the corresponding 1421 type, enum group, constant, or command, and that structure/union 1422 types and commands tag the types and names of all their members and 1423 parameters. This is essential for the automatic dependency process 1424 to work. 1425 1426If you are _modifying_ existing APIs, just make appropriate changes 1427in the existing tags. 1428 1429Once the definition is added, proceed to the next section to create 1430dependencies on the changed feature. 1431 1432 1433== API Feature Dependencies 1434 1435When you add new API elements, they will not result in corresponding changes 1436in the generated header unless they are _required_ by the interface 1437being generated. This makes it possible to include different API versions 1438and extensions in a single registry and pull them out as needed. So you must 1439introduce a dependency on new features in the corresponding tag:feature 1440tag. 1441 1442Initially, the only API feature is Vulkan 1.0, so there is only one 1443tag:feature tag in `vk.xml`. You can find it by searching 1444for the following block of `vk.xml`: 1445 1446[source,xml] 1447-------------------------------------- 1448<comment> 1449<feature api="vulkan" name="VK_VERSION_1_0" number="1.0" 1450 comment="Vulkan core API interface definitions"> 1451-------------------------------------- 1452 1453Inside the tag:feature tag are nested multiple tag:require tags. These 1454are just being used as a logical grouping mechanism for related parts of 1455Vulkan 1.0 at present, though they may have more meaningful roles in the 1456future if different API profiles are defined. 1457 1458 1459=== API Feature Walkthrough 1460 1461This section walks through the first few required API features in the 1462`vk.xml` tag:feature tag, showing how each requirement pulls in type, token, 1463and command definitions and turns those into definitions in the C header 1464file `vulkan_core.h`. 1465 1466Consider the first few lines of the tag:feature: 1467 1468[source,xml] 1469-------------------------------------- 1470<require comment="Header boilerplate"> 1471 <type name="vk_platform"/> 1472</require> 1473<require comment="API constants"> 1474 <enum name="VK_MAX_PHYSICAL_DEVICE_NAME"/> 1475 <enum name="VK_MAX_EXTENSION_NAME"/> 1476 ... 1477</require> 1478<require comment="Device initialization"> 1479 <command name="vkCreateInstance"/> 1480 ... 1481-------------------------------------- 1482 1483The first tag:require block says to require a type named `vk_platform`. 1484If you look at the beginning of the tag:types section, there is a 1485corresponding definition section: 1486 1487[source,xml] 1488-------------------------------------- 1489<type name="vk_platform">#include "vk_platform.h" 1490#define VK_MAKE_VERSION(major, minor, patch) \ 1491 ((major << 22) | (minor << 12) | patch) 1492 ... 1493-------------------------------------- 1494 1495This section is invoked by the requirement and emits a bunch of 1496boilerplate C code. The explicit dependency is not strictly required 1497since `vk_platform` will be required by many other types, but placing it 1498first causes this to appear first in the output file. 1499 1500Note that `vk_platform` does not correspond to an actual C type, but instead 1501to a collection of freeform preprocessor includes and macros and comments. 1502Most other tag:type tags do define a specific type and are much simpler, but 1503this approach can be used to inject arbitrary C into the Vulkan headers 1504*when there is no other way*. In general inserting arbitrary C is strongly 1505discouraged outside of specific special cases like this. 1506 1507The next tag:require block pulls in some compile time constants. These 1508correspond to the definitions found in the first tag:enums section of 1509`vk.xml`: 1510 1511[source,xml] 1512-------------------------------------- 1513<enums name="API Constants" 1514 comment="Vulkan hardcoded constants - not an enumerated type, part of the header boilerplate"> 1515 <enum value="256" name="VK_MAX_PHYSICAL_DEVICE_NAME"/> 1516 <enum value="256" name="VK_MAX_EXTENSION_NAME"/> 1517 ... 1518-------------------------------------- 1519 1520The third tag:require block starts pulling in some Vulkan commands. The 1521first command corresponds to the following definition found in the 1522tag:commands section of `vk.xml`: 1523 1524[source,xml] 1525-------------------------------------- 1526<commands> 1527 <command> 1528 <proto><type>VkResult</type> <name>vkCreateInstance</name></proto> 1529 <param>const <type>VkInstanceCreateInfo</type>* <name>pCreateInfo</name></param> 1530 <param><type>VkInstance</type>* <name>pInstance</name></param> 1531 </command> 1532 ... 1533-------------------------------------- 1534 1535In turn, the tag:command tag requires the tag:types `VkResult`, 1536`VkInstanceCreateInfo`, and `VkInstance` as part of its 1537definition. The definitions of these types are determined as follows: 1538 1539For `VkResult`, the corresponding required tag:type is: 1540 1541[source,xml] 1542-------------------------------------- 1543<type name="VkResult" category="enum"/> 1544-------------------------------------- 1545 1546Since this is an enumeration type, it simply links to an tag:enums tag 1547with the same name: 1548 1549[source,xml] 1550-------------------------------------- 1551<enums name="VkResult" type="enum" comment="API result codes"> 1552 <comment>Return codes (positive values)</comment> 1553 <enum value="0" name="VK_SUCCESS"/> 1554 <enum value="1" name="VK_UNSUPPORTED"/> 1555 <enum value="2" name="VK_NOT_READY"/> 1556 ... 1557 <comment>Error codes (negative values)</comment> 1558 <enum value="-1" name="VK_ERROR_OUT_OF_HOST_MEMORY" comment="A host memory allocation has failed"/> 1559 ... 1560-------------------------------------- 1561 1562For `VkInstanceCreateInfo`, the required tag:type is: 1563 1564[source,xml] 1565-------------------------------------- 1566<type category="struct" name="VkInstanceCreateInfo"> 1567 <member values="VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO"><type>VkStructureType</type> <name>sType</name></member> 1568 <member>const void* <name>pNext</name></member> 1569 <member>const <type>VkApplicationInfo</type>* <name>pAppInfo</name></member> 1570 <member>const <type>VkAllocCallbacks</type>* <name>pAllocCb</name></member> 1571 <member><type>uint32_t</type> <name>extensionCount</name></member> 1572 <member>const <type>char</type>*const* <name>ppEnabledExtensionNames</name></member> 1573</type> 1574-------------------------------------- 1575 1576This is a structure type, defining a C `struct` with all the members 1577defined in each tag:member tag in order. In addition, it requires some 1578other types, whose definitions are located by name in exactly the same 1579fashion. 1580 1581For the final direct dependency of the command, `VkInstance`, the 1582required tag:type is: 1583 1584[source,xml] 1585-------------------------------------- 1586 <comment>Types which can be void pointers or class pointers, selected at compile time</comment> 1587<type>VK_DEFINE_BASE_HANDLE(<name>VkObject</name>)</type> 1588<type>VK_DEFINE_DISP_SUBCLASS_HANDLE(<name>VkInstance</name>, <type>VkObject</type>)</type> 1589-------------------------------------- 1590 1591In this case, the type `VkInstance` is defined by a special compile time 1592macro which defines it as a derived class of `VkObject` (for `C```) or a 1593less typesafe definition (for C). This macro is not part of the type 1594dependency analysis, just the boilerplate used in the header. 1595 1596If these are the only tag:feature dependencies in `vk.xml`, the 1597resulting `vulkan_core.h` header will look like this: 1598 1599[source,c] 1600-------------------------------------- 1601#ifndef VULKAN_H_ 1602#define VULKAN_H_ 1 1603 1604#ifdef __cplusplus 1605extern "C" { 1606#endif 1607 1608/* 1609** Copyright (c) 2015-2018 The Khronos Group Inc. 1610 ... 1611*/ 1612 1613/* 1614** This header is generated from the Khronos Vulkan XML API Registry. 1615** 1616** Generated on date 20170208 1617*/ 1618 1619 1620#define VK_VERSION_1_0 1 1621#include "vk_platform.h" 1622#define VK_MAKE_VERSION(major, minor, patch) \ 1623 ((major << 22) | (minor << 12) | patch) 1624 1625// Vulkan API version supported by this file 1626#define VK_API_VERSION VK_MAKE_VERSION(0, 104, 0) 1627 1628#if defined (__cplusplus) && (VK_UINTPTRLEAST64_MAX == UINTPTR_MAX) 1629 #define VK_TYPE_SAFE_COMPATIBLE_HANDLES 1 1630#endif 1631 1632#if defined(VK_TYPE_SAFE_COMPATIBLE_HANDLES) && !defined(VK_DISABLE_TYPE_SAFE_HANDLES) 1633 #define VK_DEFINE_PTR_HANDLE(_obj) struct _obj##_T { char _dummy; }; typedef _obj##_T* _obj; 1634 #define VK_DEFINE_PTR_SUBCLASS_HANDLE(_obj, _base) struct _obj##_T : public _base##_T {}; typedef _obj##_T* _obj; 1635 1636 #define VK_DEFINE_BASE_HANDLE(_obj) VK_DEFINE_PTR_HANDLE(_obj) 1637 #define VK_DEFINE_DISP_SUBCLASS_HANDLE(_obj, _base) VK_DEFINE_PTR_SUBCLASS_HANDLE(_obj, _base) 1638 #define VK_DEFINE_NONDISP_SUBCLASS_HANDLE(_obj, _base) VK_DEFINE_PTR_SUBCLASS_HANDLE(_obj, _base) 1639#else 1640 #define VK_DEFINE_BASE_HANDLE(_obj) typedef VkUintPtrLeast64 _obj; 1641 #define VK_DEFINE_DISP_SUBCLASS_HANDLE(_obj, _base) typedef uintptr_t _obj; 1642 #define VK_DEFINE_NONDISP_SUBCLASS_HANDLE(_obj, _base) typedef VkUintPtrLeast64 _obj; 1643#endif 1644 1645typedef enum { 1646 VK_SUCCESS = 0, 1647 VK_UNSUPPORTED = 1, 1648 VK_NOT_READY = 2, 1649 ... 1650} VkResult; 1651typedef enum { 1652 VK_STRUCTURE_TYPE_APPLICATION_INFO = 0, 1653 ... 1654} VKStructureType; 1655typedef struct { 1656 VkStructureType sType; 1657 const void* pNext; 1658 const char* pAppName; 1659 uint32_t appVersion; 1660 const char* pEngineName; 1661 uint32_t engineVersion; 1662 uint32_t apiVersion; 1663} VkApplicationInfo; 1664typedef enum { 1665 VK_SYSTEM_ALLOC_TYPE_API_OBJECT = 0, 1666 ... 1667} VkSystemAllocType; 1668typedef void* (VKAPI_PTR *PFN_vkAllocFunction)( 1669 void* pUserData, 1670 size_t size, 1671 size_t alignment, 1672 VkSystemAllocType allocType); 1673typedef void (VKAPI_PTR *PFN_vkFreeFunction)( 1674 void* pUserData, 1675 void* pMem); 1676typedef struct { 1677 void* pUserData; 1678 PFN_vkAllocFunction pfnAlloc; 1679 PFN_vkFreeFunction pfnFree; 1680} VkAllocCallbacks; 1681typedef struct { 1682 VkStructureType sType; 1683 const void* pNext; 1684 const VkApplicationInfo* pAppInfo; 1685 const VkAllocCallbacks* pAllocCb; 1686 uint32_t extensionCount; 1687 const char*const* ppEnabledExtensionNames; 1688} VkInstanceCreateInfo; 1689VK_DEFINE_BASE_HANDLE(VkObject) 1690VK_DEFINE_DISP_SUBCLASS_HANDLE(VkInstance, VkObject) 1691#define VK_MAX_PHYSICAL_DEVICE_NAME 256 1692#define VK_MAX_EXTENSION_NAME 256 1693typedef VkResult (VKAPI_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance); 1694#ifndef VK_NO_PROTOTYPES 1695VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance( 1696 const VkInstanceCreateInfo* pCreateInfo, 1697 VkInstance* pInstance); 1698#endif 1699 1700#ifdef __cplusplus 1701} 1702#endif 1703 1704#endif 1705-------------------------------------- 1706 1707Note that several additional types are pulled in by the type dependency 1708analysis, but only those types, commands, and tokens required by the 1709specified features are generated. 1710 1711 1712== How To Add A Compile Time Constant 1713 1714Go to the desired tag:feature or tag:extension tag. Add (if not present) a 1715nested tag:require block labelled 1716 1717[source,xml] 1718-------------------------------------- 1719<require comment="API constants"> 1720-------------------------------------- 1721 1722In this block, add an (appropriately indented) tag like 1723 1724[source,xml] 1725-------------------------------------- 1726 <enum name="VK_THE_ANSWER"/> 1727-------------------------------------- 1728 1729Then go to the tag:enums block labelled 1730 1731[source,xml] 1732-------------------------------------- 1733<enums comment="Misc. hardcoded constants - not an enumerated type"> 1734-------------------------------------- 1735 1736In this block, add a tag whose attr:name attribute matches the attr:name 1737you defined above and whose attr:value attribute is the value to give the 1738constant: 1739 1740[source,xml] 1741-------------------------------------- 1742 <enum value="42" name="VK_THE_ANSWER"/> 1743-------------------------------------- 1744 1745 1746== How To Add A Struct or Union Type 1747 1748For this example, assume we want to define a type 1749corresponding to a C `struct` defined as follows: 1750 1751[source,c] 1752-------------------------------------- 1753typedef struct { 1754 VkStructureType sType; 1755 const void* pNext; 1756 const VkApplicationInfo* pAppInfo; 1757 const VkAllocCallbacks* pAllocCb; 1758 uint32_t extensionCount; 1759 const char*const* ppEnabledExtensionNames; 1760} VkInstanceCreateInfo; 1761-------------------------------------- 1762 1763If `VkInstanceCreateInfo` is the type of a parameter of a command in 1764the API, make sure that command's definition (see below for how to add a 1765command) puts `VkInstanceCreateInfo` in nested tag:type tags where 1766it is used. 1767 1768Otherwise, if the struct type is not used directly by a command in the API, 1769nor required by a chain of type dependencies for other commands, an explicit 1770tag:type dependency should be added to the tag:feature tag. Go to the 1771tag:types tag and search for the nested block labelled 1772 1773[source,xml] 1774-------------------------------------- 1775<require comment="Types not directly used by the API. Include e.g. structs that are not parameter types of commands, but still defined by the API."> 1776 ... 1777-------------------------------------- 1778 1779In this block, add a tag whose attr:name attribute matches the attr:name 1780of the struct type being defined: 1781 1782[source,xml] 1783-------------------------------------- 1784<require comment="API types not used by commands"> 1785 <type name="VkInstanceCreateInfo"/> 1786 ... 1787-------------------------------------- 1788 1789Then go to the tag:types tag and add a new tag:type tag defining 1790the struct names and members, somewhere below 1791the corresponding comment, like this: 1792 1793[source,xml] 1794-------------------------------------- 1795<types> 1796 ... 1797 <comment>Struct types</comment> 1798 <type category="struct" name="VkInstanceCreateInfo"> 1799 <member><type>VkStructureType</type> 1800 <name>sType</name></member> 1801 <member>const void* 1802 <name>pNext</name></member> 1803 <member>const <type>VkApplicationInfo</type>* 1804 <name>pAppInfo</name></member> 1805 <member>const <type>VkAllocCallbacks</type>* 1806 <name>pAllocCb</name></member> 1807 <member><type>uint32_t</type> 1808 <name>extensionCount</name></member> 1809 <member>const <type>char</type>*const* 1810 <name>ppEnabledExtensionNames</name></member> 1811 </type> 1812 ... 1813-------------------------------------- 1814 1815If any of the member types are types also defined in the header, make sure 1816to enclose those type names in nested tag:type tags, as shown above. Basic 1817C types should not be tagged. 1818 1819If the type is a C `union`, rather than a `struct`, then set the 1820value of the attr:category attribute to `"union"` instead of 1821`"struct"`. 1822 1823 1824== How To Add An Enumerated Type 1825 1826For this example, assume we want to define a type corresponding to a C 1827`enum` defined as follows: 1828 1829[source,c] 1830-------------------------------------- 1831typedef enum { 1832 VK_DEVICE_CREATE_VALIDATION_BIT = 0x00000001, 1833 VK_DEVICE_CREATE_MULTI_DEVICE_IQ_MATCH_BIT = 0x00000002; 1834} VkDeviceCreateFlagBits. 1835-------------------------------------- 1836 1837If `VkDeviceCreateFlagBits` is the type of a parameter to a command in 1838the API, or of a member in a structure or union, make sure that command 1839parameter or struct member's definition puts `VkDeviceCreateFlagBits` 1840in nested tag:type tags where it is used. 1841 1842Otherwise, if the enumerated type is not used directly by a command in the 1843API, nor required by a chain of type dependencies for commands and structs, 1844an explicit tag:type dependency should be added to the tag:feature tag 1845in exactly the same fashion as described above for `struct` types. 1846 1847Next, go to the line labelled 1848 1849[source,xml] 1850-------------------------------------- 1851<comment>Vulkan enumerant (token) definitions</comment> 1852-------------------------------------- 1853 1854At an appropriate point below this line, add an tag:enums tag whose 1855attr:name attribute matches the tag:type name `VkDeviceCreateFlagBits`, and 1856whose contents correspond to the individual fields of the enumerated type: 1857 1858[source,xml] 1859-------------------------------------- 1860<enums name="VkDeviceCreateFlagBits" type="bitmask"> 1861 <enum bitpos="0" name="VK_DEVICE_CREATE_VALIDATION_BIT"/> 1862 <enum bitpos="1" name="VK_DEVICE_CREATE_MULTI_DEVICE_IQ_MATCH_BIT"/> 1863</enums> 1864-------------------------------------- 1865 1866Several other attributes of the tag:enums tag can be set. In this case, 1867the attr:type attribute is set to `"bitmask"`, indicating that the 1868individual enumerants represent elements of a bitmask. 1869 1870The individual tag:enum tags define the enumerants, just like the 1871definition for compile time constants described above. In this case, because 1872the enumerants are bits in a bitmask, their values are specified using the 1873attr:bitpos attribute. The value of this attribute must be an integer in 1874the range [0,31] specifying a single bit number, and the resulting value 1875is printed as a hexadecimal constant corresponding to that bit. 1876 1877It is also possible to specify enumerant values using the attr:value 1878attribute, in which case the specified numeric value is passed through to 1879the C header unchanged. 1880 1881 1882== How to Add A Command 1883 1884For this example, assume we want to define the command: 1885 1886[source,c] 1887-------------------------------------- 1888VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance( 1889 const VkInstanceCreateInfo* pCreateInfo, 1890 VkInstance* pInstance); 1891-------------------------------------- 1892 1893Commands must always be explicitly required in the tag:feature tag. In 1894that tag, you can use an existing tag:require block including API features 1895which the new command should be grouped with, or define a new block. For 1896this example, add a new block, and require the command by using the 1897tag:command tag inside that block: 1898 1899[source,xml] 1900-------------------------------------- 1901<feature api="vulkan" name="VK_VERSION_1_0" number="1.0" comment="Vulkan core API interface definitions"> 1902 ... 1903 <require comment="Device initialization"> 1904 <command name="vkCreateInstance"/> 1905 </require> 1906 ... 1907</feature> 1908-------------------------------------- 1909 1910The tag:require block may include a attr:comment attribute whose value 1911is a descriptive comment of the contents required within that block. The 1912comment is not currently used in header generation, but might be in the 1913future, so use comments which are polite and meaningful to users of 1914the generated header files. 1915 1916Then go to the tag:commands tag and add a new tag:command tag defining 1917the command, preferably sorted into alphabetic order with other commands for 1918ease of reading, as follows: 1919 1920[source,xml] 1921-------------------------------------- 1922<commands comment="Vulkan command definitions"> 1923 ... 1924 <command> 1925 <proto><type>VkResult</type> 1926 <name>vkCreateInstance</name></proto> 1927 <param>const <type>VkInstanceCreateInfo</type>* 1928 <name>pCreateInfo</name></param> 1929 <param><type>VkInstance</type>* 1930 <name>pInstance</name></param> 1931 </command> 1932 ... 1933</commands> 1934-------------------------------------- 1935 1936The tag:proto tag defines the return type and function name of the 1937command. The tag:param tags define the command's parameters in the order 1938in which they are passed, including the parameter type and name. The contents 1939are laid out in the same way as the structure tag:member tags described 1940previously. 1941 1942 1943== More Complicated API Representations 1944 1945The registry schema can represent a good deal of additional information, for 1946example by creating multiple tag:feature tags defining different API 1947versions and extensions. This capability is not yet relevant to Vulkan. 1948Those capabilities will be documented as they are needed. 1949 1950 1951== More Complicated Output Formats And Other Languages 1952 1953The registry schema is oriented towards C-language APIs. Types and commands 1954are defined using syntax which is a subset of C, especially for structure 1955members and command parameters. It would be possible to use a 1956language-independent syntax for representing such information, but since we 1957are writing a C API, any such representation would have to be converted into 1958C anyway at some stage. 1959 1960The `vulkan.h` header is written using an _output generator_ object 1961in the Python scripts. This output generator is specialized for C, but the 1962design of the scripts is intended to support writing output generators for 1963other languages as well as purposes such as documentation (e.g. generating 1964asciidoc fragments corresponding to types and commands for use in the API 1965specification and reference pages). When targeting other languages, the 1966amount of parsing required to convert type declarations into other languages 1967is small. However, it will probably be necessary to modify some of the 1968boilerplate C text, or specialize the tags by language, to support such 1969generators. 1970 1971 1972== Additional Semantic Tagging 1973 1974The schema is being extended to support semantic tags describing 1975various properties of API features, such as: 1976 1977 * constraints on allowed scalar values to function parameters 1978 (non-`NULL`, normalized floating-point, etc.) 1979 * length of arrays corresponding to function pointer parameters 1980 * miscellaneous properties of commands such as whether the application 1981 or system is responsible for threadsafe use; which queues they may 1982 be issued on; whether they are aliases or otherwise related to other 1983 commands; etc. 1984 1985These tags will be used by other tools for purposes such as helping 1986create validation layers, generating serialization code, and so on. We 1987would like to eventually represent everything about the API that is 1988amenable to automatic processing within the registry schema. Please make 1989suggestions on the Github issue tracker. 1990 1991 1992[[general:stability]] 1993== Stability of the XML Database and Schema 1994 1995The Vulkan XML schema is evolving in response to corresponding changes 1996in the Vulkan API and ecosystem. Most such change will probably be 1997confined to adding attributes to existing tags and properly expressing 1998the relationships to them, and making API changes corresponding to 1999accepted feature requests. Changes to the schema should be described in 2000the <<changelog,change log>> of this document. Changes to the `.xml` 2001files and Python scripts are logged in Github history. 2002 2003 2004[[changelog]] 2005= Change Log 2006 2007 * 2018-07-07 - Add optional attr:promotedto, attr:deprecatedby, and 2008 attr:obsoletedby attributes to tag:extension tags. 2009 * 2018-06-25 - Remove attr:vendorids tags for Khronos vendor IDs. 2010 * 2018-04-15 - Add attr:requiresCore. 2011 * 2018-03-07 - Updated for Vulkan 1.1 release. 2012 * 2018-02-21 - Add descriptions of the attr:extnumber and attr:alias 2013 attributes used for defining tag:enum attributes, the attr:alias 2014 attribute used for defining tag:type aliases, the attr:name and 2015 attr:alias attributes used for defining tag:command aliases, the 2016 attr:platform attribute of tag:extension tags, and the attr:feature 2017 attribute of tag:require tags; and update the document to the header 2018 naming and grouping scheme used starting in Vulkan 1.1. 2019 * 2018-01-07 - Add tag:platforms and tag:platform tags for describing 2020 Vulkan platform names and preprocessor symbols. 2021 * 2017-09-10 - Define syntax of member and parameter attr:altlen 2022 attributes, for use by code generators. 2023 * 2017-09-01 - Define syntax of member and parameter attr:len attributes 2024 consistently and correctly for current uses of latexmath: 2025 * 2017-08-24 - Note that the tag:extension attribute attr:type must be 2026 specified if the extension is not disabled. 2027 * 2017-07-27 - Finish removing validextensionstructs attribute and 2028 replacing it with structextends. 2029 * 2017-07-14 - Add comment attributes or tags as valid content in several 2030 places, replacing XML comments which could not be preserved by XML 2031 transformation tools. 2032 * 2017-02-20 - Change to asciidoctor markup and move into the 2033 specification source directory for ease of building. 2034 * 2016-09-27 - Remove tag:validity and tag:usage tags, since these 2035 explicit usage statements have been moved to the specification source. 2036 * 2016-08-26 - Update for the single-branch model. 2037 * 2016-07-28 - Add attr:type and attr:requires attributes to tag:extension 2038 tags. 2039 * 2016-02-22 - Change math markup in attr:len attributes to use 2040 asciidoc `latexmath:[$` and `$]` delimiters. 2041 * 2016-02-19 - Add attr:successcodes and attr:errorcodes attributes of 2042 tag:command tags. Add a subsection to the introduction describing 2043 the schema choices and how to file issues against the registry. 2044 * 2016-02-07 - Add attr:vendorids tags for Khronos vendor IDs. 2045 * 2015-12-10 - Add attr:author and attr:contact attributes for 2046 tag:extension tags. 2047 * 2015-12-07 - Move `vulkan/vulkan.h` to a subdirectory. 2048 * 2015-12-01 - Add tag:tags tags for author tags. 2049 * 2015-11-18 - Bring documentation and schema up to date for extension 2050 enumerants. 2051 * 2015-11-02 - Bring documentation and schema up to date with several 2052 recent merges, including tag:validity tags. Still out of date WRT 2053 extension enumerants, but that will change soon. 2054 * 2015-09-08 - Rename `threadsafe` attribute to attr:externsync, and 2055 `implicitunsafeparams` tag to attr:implicitexternsync. 2056 * 2015-09-07 - Update tag:command tag description to remove the 2057 attr:threadsafe attribute and replace it with a combination of 2058 attr:threadunsafe attributes on individual parameters, and 2059 tag:implicitunsafeparams tags describing additional unsafe objects 2060 for the command. 2061 * 2015-08-04 - Add `basetype` and `funcpointer` attr:category values 2062 for type tags, and explain the intended use and order in which types 2063 in each category are emitted. 2064 * 2015-07-02 - Update description of Makefile targets. Add descriptions of 2065 attr:threadsafe, attr:queues, and attr:renderpass attributes of 2066 <<tag-command,tag:command>> tags, and of attr:modified attributes of 2067 <<tag-command:param,tag:param>> tags. 2068 * 2015-06-17 - add descriptions of allowed attr:category attribute 2069 values of tag:type tags, used to group and sort related categories 2070 of declarations together in the generated header. 2071 * 2015-06-04 - Add <<examples,examples of making changes and additions>> 2072 to the registry. 2073 * 2015-06-03 - Move location to new `vulkan` Git repository. Add 2074 definition of tag:type tags for C struct/unions. Start adding 2075 <<examples,examples of making changes>>. 2076 * 2015-06-02 - Branch from OpenGL specfile documentation and bring up 2077 to date with current Vulkan schema. 2078 * 2015-07-10 - Remove contractions to match the style guide. 2079 * 2015-07-19 - Move this document from LaTeX to asciidoc source format and 2080 make minor changes to markup. 2081