• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2013-2021 The Khronos Group Inc.
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5= The Khronos^®^ Vulkan^®^ API Registry
6Jon Leech
7:data-uri:
8:icons: font
9:toc2:
10:toclevels: 3
11:numbered:
12:source-highlighter: rouge
13:rouge-style: github
14:doctype: book
15:imagewidth: 800
16:fullimagewidth: width="800"
17:cl: :
18
19// Various special / math symbols. This is easier to edit with than Unicode.
20include::{config}/attribs.txt[]
21
22:leveloffset: 1
23
24<<<<
25
26include::{config}/copyright-ccby.txt[]
27
28<<<<
29
30[[introduction]]
31= Introduction
32
33This document describes the Khronos Vulkan API Registry schema, and provides
34some additional information about using the registry and scripts to generate
35a variety of outputs, including C header files as well as several types of
36asciidoc include files used in the Vulkan API specification and reference
37pages.
38The underlying XML files and scripts are located on the Khronos public
39Github server at URL
40
41https://github.com/KhronosGroup/Vulkan-Docs
42
43The authoritative copy of the Registry is maintained in the default branch,
44currently `main`.
45
46The registry uses an XML representation of the Vulkan API, together with a
47set of Python scripts to manipulate the registry once loaded.
48The scripts rely on the Python `etree` package to parse and operate on XML.
49An XML schema and validator target are included.
50
51The schema is based on, but not identical to that used for the previously
52published OpenGL, OpenGL ES and EGL API registries.
53It was extended to represent additional types and concepts not needed for
54those APIs, such as structure and enumerant types, as well as additional
55types of registered information specific to Vulkan.
56
57The Vulkan C header files generated from the registry are checked into a
58separate repository under
59
60https://github.com/KhronosGroup/Vulkan-Headers/
61
62
63== Schema Choices
64
65The XML schema is not pure XML all the way down.
66In particular, command return types/names and parameters, and structure
67members, are described in mixed-mode tag containing C declarations of the
68appropriate information, with some XML nodes annotating particular parts of
69the declaration such as its base type and name.
70This choice is based on prior experience with the SGI `.spec` file format
71used to describe OpenGL, and greatly eases human reading and writing the
72XML, and generating C-oriented output.
73The cost is that people writing output generators for other languages will
74have to include enough logic to parse the C declarations and extract the
75relevant information.
76
77People who do not find the supplied Python scripts to suit their needs are
78likely to write their own parsers, interpreters, and/or converters operating
79on the registry XML.
80We hope that we have provided enough information in this document, the RNC
81schema (`registry.rnc`), and comments in the Registry (`vk.xml`) itself to
82enable such projects.
83If not and you need clarifications; if you have other problems using the
84registry; or if you have proposed changes and enhancements, then please file
85issues on Khronos' public Github project at
86
87https://github.com/KhronosGroup/Vulkan-Docs/issues
88
89Please tag your issues with `[Registry]` in the subject line to help us
90categorize them.
91We have considered separating the registry from the specification source
92into a separate repository, but since there is so much specification valid
93usage language imbedded in the registry XML, this is unlikely to happen.
94
95
96[[starting]]
97= Getting Started
98
99See
100https://gitlab.khronos.org/vulkan/vulkan/blob/main/xml/README.adoc[`xml/README.adoc`]
101in the `Vulkan-Docs` repository for information on required toolchain
102components such as Python 3, pass:[g++], and GNU make.
103
104Once you have the right tools installed, perform the following steps:
105
106  * Check out the `Vulkan-Docs` repository linked above from Khronos Github
107    (there are instructions at the link)
108  * `cd` to the root directory in your checked-out repo
109  * Switch to the default branch (`main`).
110  * Invoke `make clean ; make install ; make test`
111
112This should regenerate `vulkan_core.h` and a variety of platform-specific
113headers, install them in `../include/vulkan/`, and verify that the headers
114build properly.
115If you build at the latest repository tag, the resulting headers should be
116identical to the latest versions in the
117link:https://github.com/KhronosGroup/Vulkan-Headers/[Vulkan-Headers
118repository].
119
120The `install` target also generates source code for a simple extension
121loader library in `../src/ext_loader/`.
122
123Other Makefile targets in `xml/` include:
124
125  * `validate` - validate `vk.xml` against the XML schema.
126    Recommended if you are making nontrivial changes.
127  * The asciidoc includes used by the Specification and Reference Pages are
128    built using the 'make generated' target in the parent directory
129    Makefile, although they use the scripts and XML in this directory.
130    These files are generated dynamically when building the specs, since
131    their contents depend on the exact set of extensions the Specification
132    is being built to include.
133
134If you just want to modify the API, changing `vk.xml` and running `make`
135should be all that is needed.
136See <<examples>> for some examples of modifying the XML.
137
138If you want to use the registry for reasons other than generating the header
139file, extension loader, and asciidoc includes, or to generate headers for
140languages other than C, start with the Makefile rules and the files
141`vk.xml` and scripts `genvk.py`, `reg.py`, and `generator.py`.
142The scripts are described below and are all located in the `scripts`
143directory under the repository root.
144
145== Header Generation Script - `genvk.py`
146
147When generating header files using the `genvk.py` script, an API name and
148profile name are required, as shown in the Makefile examples.
149Additionally, specific API versions and extensions can be required or
150excluded.
151Based on this information, the generator script extracts the relevant
152interfaces and creates a C-language header file for them.
153`genvk.py` contains predefined generator options for the current Vulkan
154Specification release.
155
156The generator script is intended to be generalizable to other languages by
157writing new generator classes.
158Such generators would have to rewrite the C types and definitions in the XML
159to something appropriate to their language.
160
161
162== Registry Processing Script - `reg.py`
163
164XML processing is done in `reg.py`, which contains several objects and
165methods for loading registries and extracting interfaces and extensions for
166use in header generation.
167There is some internal documentation in the form of comments, although
168nothing more extensive exists yet.
169
170
171== Output Generator Script - `generator.py`
172
173Once the registry is loaded, the `COutputGenerator` class defined in
174`generator.py` is used to create a header file.
175The `DocOutputGenerator` class is used to create the asciidoc include files.
176Output generators for other purposes can be added as needed.
177There are a variety of output generators included:
178
179  * `cgenerator.py` - generate C header file
180  * `docgenerator.py` - generate asciidoc includes for APIs
181  * `hostsyncgenerator.py` - generate host sync table includes for APIs
182  * `validitygenerator.py` - generate validity language includes
183  * `pygenerator.py` - generate a Python dictionary-based encoding of
184    portions of the registry, used during spec generation
185  * `extensionStubSource.py` - generate a simple C extension loader.
186
187
188[[schema]]
189= Vulkan Registry Schema
190
191The format of the Vulkan registry is a top level tag:registry tag containing
192tag:types, tag:enums, tag:commands, tag:feature, and tag:extension tags
193describing the different elements of an API, as explained below.
194This description corresponds to a formal Relax NG schema file,
195`registry.rnc`, against which the XML registry files can be validated.
196
197At present the only registry in this schema is the core Vulkan API registry,
198`vk.xml`.
199
200
201[[schema:profile]]
202== Profiles
203
204Types and enumerants can have different definitions depending on the API
205profile requested.
206This capability is not used in the current Vulkan API but may be in the
207future.
208Features and extensions can include some elements conditionally depending on
209the API profile requested.
210
211
212[[schema:apiname]]
213== API Names
214
215Specific API versions features and extensions can be tagged as belonging to
216to classes of features with the use of _API names_.
217This is intended to allow multiple closely-related API specifications in the
218same family - such as desktop and mobile specifications - to share the same
219XML.
220An API name is an arbitrary alphanumeric string, although it should be
221chosen to match the corresponding API.
222For example, Vulkan and OpenXR use `vulkan` and `openxr` as their API names,
223respectively.
224
225The attr:api attribute of the tag:feature tag and the attr:supported
226attribute of the tag:extensions tag must be comma-separated lists of one or
227more API names, all of which match that feature or extension.
228When generating headers and other artifacts from the XML, an API name may be
229specified to the processing scripts, causing the selection of only those
230features and extensions whose API names match the specified name.
231
232Several other tags for defining types and groups of types also support
233attr:api attributes.
234If present, the attribute value must be a comma-separated list of one or
235more API names.
236This allows specializing a definition for different, closely related APIs.
237
238
239[[schema:root]]
240= Registry Root (tag:registry tag)
241
242A tag:registry contains the entire definition of one or more related APIs.
243
244== Attributes of tag:registry tags
245
246None.
247
248== Contents of tag:registry tags
249
250Zero or more of each of the following tags, normally in this order (although
251order should not be important):
252
253  * tag:comment - Contains arbitrary text, such as a copyright statement.
254  * <<tag-platforms,tag:platforms>> - defines platform names corresponding
255    to platform-specific <<tag-extension,API extensions>>.
256  * <<tag-tags,tag:tags>> - defines author IDs used for extensions and
257    layers.
258    Author IDs are described in detail in the "`Layers & Extensions`"
259    section of the "`Vulkan Documentation and Extensions: Procedures and
260    Conventions`" document.
261  * <<tag-types,tag:types>> - defines API types.
262    Usually only one tag is used.
263  * <<tag-enums,tag:enums>> - defines API token names and values.
264    Usually multiple tags are used.
265    Related groups may be tagged as an enumerated type corresponding to a
266    tag:type tag, and resulting in a C `enum` declaration.
267    This ability is heavily used in the Vulkan API.
268  * <<tag-commands,tag:commands>> - defines API commands (functions).
269    Usually only one tag is used.
270  * <<tag-feature,tag:feature>> - defines API feature interfaces (API
271    versions, more or less).
272    One tag per feature set.
273  * <<tag-extensions,tag:extensions>> - defines API extension interfaces.
274    Usually only one tag is used, wrapping many extensions.
275  * <<tag-formats,tag:formats>> - defines properties of image formats.
276    Only one tag is used, wrapping all the formats.
277  * <<tag-spirvextensions,tag:spirvextensions>> - defines relationship
278    between SPIR-V extensions and API interfaces which enable each
279    extension.
280    Only one tag is used, wrapping all the SPIR-V extensions.
281  * <<tag-spirvcapabilities,tag:spirvcapabilities>> - defines relationship
282    between SPIR-V capabilities and API interfaces which enable each
283    capability.
284    Only one tag is used, wrapping all the SPIR-V capabilities.
285
286
287[[tag-comment]]
288=== Comment Tags (tag:comment tag)
289
290A tag:comment tag contains an arbitrary string, and is unused.
291Comment tags may appear in multiple places in the schema, as described
292below.
293Comment tags are removed by output generators if they would otherwise appear
294in generated headers, asciidoc include files, etc.
295
296
297[[tag-platforms]]
298= Platform Name Blocks (tag:platforms tag)
299
300A tag:platforms contains descriptions of platform IDs for platforms
301supported by window system-specific extensions to Vulkan.
302
303== Attributes of tag:platforms tags
304
305  * attr:comment - optional.
306    Arbitrary string (unused).
307
308== Contents of tag:platforms tags
309
310Zero or more tag:platform tags, in arbitrary order (though they are
311typically ordered by sorting on the platform name).
312
313
314[[tag-platform]]
315= Platform Names (tag:platform tag)
316
317A tag:platform tag describes a single platform name.
318
319== Attributes of tag:platform tags
320
321  * attr:name - required.
322    The platform name.
323    This must be a short alphanumeric string corresponding to the platform
324    name, valid as part of a C99 identifier.
325    Lower-case is preferred.
326    In some cases, it may be desirable to distinguish a subset of platform
327    functionality from the entire platform.
328    In these cases, the platform name should begin with the entire platform
329    name, followed by `_` and the subset name.
330+
331--
332[NOTE]
333.Note
334====
335For example,
336
337`name="xlib"`
338
339is used for the X Window System, Xlib client library platform.
340
341`name="xlib_xrandr"`
342
343is used for the XRandR functionality within the `xlib` platform.
344====
345--
346  * attr:protect - required.
347    This must be a C99 preprocessor token beginning with `VK_USE_PLATFORM_`
348    followed by the platform name, converted to upper case, followed by `_`
349    and the extension suffix of the corresponding window system-specific
350    extension supporting the platform.
351+
352--
353[NOTE]
354.Note
355====
356For example,
357
358`protect="VK_USE_PLATFORM_XLIB_XRANDR_EXT"`
359
360is used for the `xlib_xrandr` platform name.
361====
362--
363  * attr:comment - optional.
364    Arbitrary string (unused).
365
366== Contents of tag:platform tags
367
368No contents are allowed.
369All information is contained in the attributes.
370
371
372[[tag-tags]]
373= Author ID Blocks (tag:tags tag)
374
375A tag:tags tag contains tag:authorid tags describing reserved author IDs
376used by extension and layer authors.
377
378== Attributes of tag:tags tags
379
380  * attr:comment - optional.
381    Arbitrary string (unused).
382
383== Contents of tag:tags tags
384
385Zero or more tag:tag tags, in arbitrary order (though they are typically
386ordered by sorting on the author ID).
387
388
389[[tag-tag]]
390= Author IDs (tag:tag tag)
391
392A tag:tag tag contains information defining a single author ID.
393
394== Attributes of tag:tag tags
395
396  * attr:name - required.
397    The author ID, as registered with Khronos.
398    A short, upper-case string, usually an abbreviation of an author,
399    project or company name.
400  * attr:author - required.
401    The author name, such as a full company or project name.
402  * attr:contact - required.
403    The contact who registered or is currently responsible for extensions
404    and layers using the ID, including sufficient contact information to
405    reach the contact such as individual name together with email address,
406    Github username, or other contact information.
407
408== Contents of tag:tag tags
409
410No contents are allowed.
411All information is contained in the attributes.
412
413
414[[tag-types]]
415= API Type Blocks (tag:types tag)
416
417A tag:types tag contains definitions of derived types used in the API.
418
419== Attributes of tag:types tags
420
421  * attr:comment - optional.
422    Arbitrary string (unused).
423
424== Contents of tag:types tags
425
426Zero or more tag:type and tag:comment tags, in arbitrary order (though they
427are typically ordered by putting dependencies of other types earlier in the
428list).
429The tag:comment tags are used mostly to indicate grouping of related types.
430
431
432[[tag-type]]
433= API Type (tag:type tag)
434
435A tag:type tag contains information which can be used to generate C code
436corresponding to the type.
437In many cases, this is simply legal C code, with attributes or embedded tags
438denoting the type name and other types used in defining this type.
439In some cases, additional attribute and embedded type information is used to
440generate more complicated C types.
441
442== Attributes of tag:type tags
443
444  * attr:requires - optional.
445    Another type name this type requires to complete its definition.
446  * attr:name - optional.
447    Name of this type (if not defined in the tag body).
448  * attr:alias - optional.
449    Another type name which this type is an alias of.
450    Must match the name of another tag:type element.
451    This is typically used when promoting a type defined by an extension to
452    a new core version of the API.
453    The old extension type is still defined, but as an alias of the new
454    type.
455  * attr:api - optional <<schema:apiname, API names>> for which this
456    definition is specialized, so that different APIs may have different
457    definitions for the same type.
458    This definition is only used if the requested API name matches the
459    attribute.
460    May be used to address subtle incompatibilities.
461  * attr:category - optional.
462    A string which indicates that this type contains a more complex
463    structured definition.
464    At present the only accepted categories are `basetype`, `bitmask`,
465    `define`, `enum`, `funcpointer`, `group`, `handle`, `include`, `struct`,
466    and `union`, as described below.
467  * attr:comment - optional.
468    Arbitrary string (unused).
469  * attr:parent - only applicable if `"category"` is `handle`.
470    Notes another type with the `handle` category that acts as a parent
471    object for this type.
472  * attr:returnedonly - only applicable if `"category"` is `struct` or
473    `union`.
474    Notes that this struct/union is going to be filled in by the API, rather
475    than an application filling it out and passing it to the API.
476  * attr:structextends only applicable if category is `struct` or `union`.
477    This is a comma-separated list of structures whose `pNext` can include
478    this type.
479    This should usually only list the top-level structure that is extended,
480    for all possible extending structures.
481    This will generate a validity statement on the top level structure that
482    validates the entire chain in one go, rather than each extending
483    structure repeating the list of valid structs.
484    There is no need to set the attr:noautovalidity attribute on the `pNext`
485    members of extending structures.
486  * attr:allowduplicate - only applicable if attr:category is `"struct"`.
487    If `"true"`, then structures whose `pNext` chains include this structure
488    may include more than one instance of it.
489  * attr:objtypeenum - only applicable at present if attr:category is
490    `"handle"`.
491    Specifies the name of a `VkObjectType` enumerant which corresponds to
492    this type.
493    The enumerant must be defined.
494
495== Contents of tag:type tags
496
497The valid contents depend on the attr:category attribute.
498
499=== Enumerated types - attr:category `"enum"`
500
501If the attr:category tag has the value `enum`, the type is a C enumeration.
502The body of the tag is ignored in this case.
503The value of the attr:name attribute must be provided and must match the
504attr:name attribute of a <<tag-enums,tag:enums>> tag.
505The enumerant values defined within the tag:enums tag are used to generate a
506C `enum` type declaration.
507
508=== Structure types - attr:category `"struct"` or `"union"`
509
510If the attr:category tag has the values `struct` or `union`, the type is a C
511structure or union, respectively.
512In this case, the attr:name attribute must be provided, and the contents of
513the tag:type tag are a series of tag:member tags defining the members of the
514aggregate type, in order, interleaved with any number of tag:comment tags.
515
516==== Structure member (tag:member) tags
517
518The tag:member tag defines the type and name of a structure or union member.
519
520==== Attributes of tag:member tags
521
522  * attr:values - only valid on the `sType` member of a struct.
523    This is a comma-separated list of enumerant values that are valid for
524    the structure type; usually there is only a single value.
525  * attr:len - if the member is an array, len may be one or more of the
526    following things, separated by commas (one for each array indirection):
527    another member of that struct; `"null-terminated"` for a string; `"1"`
528    to indicate it is just a pointer (used for nested pointers); or an
529    equation in math markup for incorporation in the specification (a LaTeX
530    math expression delimited by `latexmath:[` and `]`.
531    The only variables in the equation should be the names of members of the
532    structure.
533  * attr:altlen - if the attr:len attribute is specified, and contains a
534    `latexmath:` equation, this attribute should be specified with an
535    equivalent equation using only C builtin operators, C math library
536    function names, and variables as allowed for attr:len.
537    It must be a valid C99 expression whose result is equal to attr:len for
538    all possible inputs.
539    It is a comma separated list that has size equal to only the `latexmath`
540    item count in attr:len list.
541    This attribute is intended to support consumers of the XML who need to
542    generate validation code from the allowed length.
543  * attr:externsync - denotes that the member should be externally
544    synchronized when accessed by Vulkan
545  * attr:optional - optional.
546    A value of `"true"` or `"false"` determines whether this member can be
547    omitted by providing `NULL` (for pointers), `VK_NULL_HANDLE` (for
548    handles), or 0 (for other scalar types).
549    If the member is a pointer to one of those types, multiple values may be
550    provided, separated by commas - one for each pointer indirection.
551    If not present, the value is assumed to be `"false"` (the member must
552    not be omitted).
553    Structure members with name `pNext` must always be specified with
554    `optional="true"`, since there is no requirement that any member of a
555    `pNext` chain have a following member in the chain.
556+
557--
558[NOTE]
559.Note
560====
561While the attr:optional attribute can be used for scalar types such as
562integers, it does not affect the output generators included with the Vulkan
563Specification.
564In this case, the attribute serves only as an indicator to human readers of
565the XML.
566====
567--
568  * attr:selector - optional.
569    If the member is a union, attr:selector identifies another member of the
570    struct that is used to select which of that union's members are valid.
571  * attr:selection - optional.
572    For a member of a union, attr:selection identifies a value of the
573    attr:selector that indicates this member is valid.
574  * attr:noautovalidity - prevents automatic validity language being
575    generated for the tagged item.
576    Only suppresses item-specific validity - parenting issues etc.
577    are still captured.
578    It must also be used for structures that have no implicit validity when
579    such structure has explicit validity.
580  * attr:limittype - only applicable for members of
581    VkPhysicalDeviceProperties and VkPhysicalDeviceProperties2, their
582    substrucutres, and extensions.
583    Specifies the type of a device limit.
584    This type describes how a value might be compared with the value of a
585    member in order to check whether it fits the limit.
586    Valid values:
587  ** `"min"` and `"max"` denote minimum and maximum limits.
588     They may also apply to arrays and `VkExtent*D`.
589  ** `"bitmask"` corresponds to bitmasks and `VkBool32`, where set bits
590     indicate the presence of a capability
591  ** `"range"` specifies a [min, max] range
592  ** `"struct"` means that the member's fields should be compared.
593  ** `"noauto"` limits cannot be trivially compared.
594     This is the default value, if unspecified.
595  * attr:objecttype - only applicable for members which are `uint64_t`
596    values representing a Vulkan obejct handle.
597    Specifies the name of another member which must be a `VkObjectType` or
598    `VkDebugReportObjectTypeEXT` value specifying the type of object the
599    handle refers to.
600
601==== Contents of tag:member tags
602
603The text elements of a tag:member tag, with all other tags removed, is a
604legal C declaration of a struct or union member.
605In addition it may contain several semantic tags:
606
607  * The tag:type tag is optional.
608    It contains text which is a valid type name found in another tag:type
609    tag, and indicates that this type must be previously defined for the
610    definition of the command to succeed.
611    Builtin C types should not be wrapped in tag:type tags.
612  * The tag:name tag is required, and contains the struct/union member name
613    being described.
614  * The tag:enum tag is optional.
615    It contains text which is a valid enumerant name found in another
616    tag:type tag, and indicates that this enumerant must be previously
617    defined for the definition of the command to succeed.
618    Typically this is used to semantically tag static array lengths.
619  * The tag:comment tag is optional.
620    It contains an arbitrary string (unused).
621
622
623=== All other types
624
625If the attr:category attribute is one of `basetype`, `bitmask`, `define`,
626`funcpointer`, `group`, `handle` or `include`, or is not specified, tag:type
627contains text which is legal C code for a type declaration.
628It may also contain embedded tags:
629
630  * tag:type - nested type tags contain other type names which are required
631    by the definition of this type.
632  * tag:apientry/ - insert a platform calling convention macro here during
633    header generation, used mostly for function pointer types.
634  * tag:name - contains the name of this type (if not defined in the tag
635    attributes).
636  * tag:bitvalues - contains the name of the enumeration defining flag
637    values for a `bitmask` type.
638    Ignored for other types.
639
640There is no restriction on which sorts of definitions may be made in a given
641category, although the contents of tags with attr:category `enum`, `struct`
642or `union` are interpreted specially as described above.
643
644However, when generating the header, types within each category are grouped
645together, and categories are generated in the order given by the following
646list.
647Therefore, types in a category should correspond to the intended purpose
648given for that category.
649If this recommendation is not followed, it is possible that the resulting
650header file will not compile due to out-of-order type dependencies.
651The intended purpose of each category is:
652
653  * `include` (`#include`) directives)
654  * `define` (macro `#define` directives)
655  * `basetype` (built-in C language types; scalar API typedefs, such as the
656    definition of `VkFlags`; and types defined by external APIs, such as an
657    underlying OS or window system
658  * `handle` (invocations of macros defining scalar types such as
659    `VkInstance`)
660  * `enum` (enumeration types and `#define` for constant values)
661  * `group` (currently unused)
662  * `bitmask` (enumeration types whose members are bitmasks)
663  * `funcpointer` (function pointer typedefs)
664  * `struct` and `union` together (struct and union types)
665
666
667[[tag-types:example]]
668== Example of a tag:types tag
669
670[source,xml]
671--------------------------------------
672<types>
673    <type name="stddef">#include &lt;stddef.h&gt;</type>
674    <type requires="stddef">typedef ptrdiff_t <name>VKlongint</name>;</type>
675    <type name="VkEnum" category="enum"/>
676    <type category="struct" name="VkStruct">
677        <member><type>VkEnum</type> <name>srcEnum</name></member>
678        <member><type>VkEnum</type> <name>dstEnum</name></member>
679    </type>
680</types>
681
682<enums name="VkEnum" type="enum">
683    <enum value="0" name="VK_ENUM_ZERO"/>
684    <enum value="42" name="VK_ENUM_FORTY_TWO"/>
685</enums>
686--------------------------------------
687
688The `VkStruct` type is defined to require the types `VkEnum` and `VKlongint`
689as well.
690If `VkStruct` is in turn required by a command or another type during header
691generation, it will result in the following declarations:
692
693[source,c]
694--------------------------------------
695#include <stddef.h>
696typedef ptrdiff_t VKlongint.
697
698typedef enum {
699    VK_ENUM_ZERO = 0,
700    VK_ENUM_FORTY_TWO = 42
701} VkEnum;
702
703typedef struct {
704    VkEnum    dstEnum;
705    VkLongint dstVal;
706} VkStruct;
707--------------------------------------
708
709Note that the angle brackets around `stddef.h` are represented as XML
710entities in the registry.
711This could also be done using a CDATA block but unless there are many
712characters requiring special representation in XML, using entities is
713preferred.
714
715
716[[tag-enums]]
717= Enumerant Blocks (tag:enums tag)
718
719The tag:enums tags contain individual tag:enum tags describing each of the
720token names used in the API.
721In some cases these correspond to a C `enum`, and in some cases they are
722simply compile time constants (e.g. `#define`).
723
724[NOTE]
725.Note
726====
727It would make more sense to call these `const` or `define` tags.
728This is a historical hangover from the OpenGL XML format which this schema
729was based on.
730====
731
732
733== Attributes of tag:enums tags
734
735  * attr:name - optional.
736    String naming the C `enum` type whose members are defined by this enum
737    group.
738    If present, this attribute should match the attr:name attribute of a
739    corresponding tag:type tag.
740  * attr:type - optional.
741    String describing the data type of the values of this group of enums.
742    At present the only accepted categories are `enum` and `bitmask`, as
743    described below.
744  * attr:start, attr:end - optional.
745    Integers defining the start and end of a reserved range of enumerants
746    for a particular vendor or purpose.
747    attr:start must be less than or equal to attr:end.
748    These fields define formal enumerant allocations, and are made by the
749    Khronos Registrar on request from implementors following the enum
750    allocation policy.
751  * attr:vendor - optional.
752    String describing the vendor or purpose to whom a reserved range of
753    enumerants is allocated.
754  * attr:comment - optional.
755    Arbitrary string (unused).
756  * attr:bitwidth - optional.
757    Bit width required for the generated enum value type.
758    If omitted, a default value of 32 is used.
759
760== Contents of tag:enums tags
761
762Each tag:enums block contains zero or more tag:enum, tag:unused, and
763tag:comment tags, in arbitrary order (although they are typically ordered by
764sorting on enumerant values, to improve human readability).
765
766== Example of tag:enums tags
767
768<<tag-types:example,An example>> showing a tag with attribute
769attr:type`="enum"` is given above.
770The following example is for non-enumerated tokens.
771
772[source,xml]
773--------------------------------------
774<enums>
775    <enum value="256" name="VK_MAX_EXTENSION_NAME"/>
776    <enum value="MAX_FLOAT"  name="VK_LOD_CLAMP_NONE"/>
777</enums>
778--------------------------------------
779
780When processed into a C header, and assuming all these tokens were required,
781this results in
782
783[source,c]
784--------------------------------------
785#define VK_MAX_EXTENSION_NAME   256
786#define VK_LOD_CLAMP_NONE       MAX_FLOAT
787--------------------------------------
788
789
790[[tag-enum]]
791= Enumerants (tag:enum tag)
792
793Each tag:enum tag defines a single Vulkan (or other API) token.
794
795== Attributes of tag:enum tags
796
797  * attr:value is a numeric value in the form of a legal C expression when
798    evaluated at compile time in the generated header files.
799    This is usually either a literal integer value or the name of an alias
800    for a previously defined value, though more complex expressions are
801    sometimes employed for <<compile-time-constants, compile time
802    constants>>.
803  * attr:bitpos is a literal integer bit position in a bitmask.
804    The bit position must be in the range [0,30] when used as a flag bit in
805    a `Vk*FlagBits` data type.
806    Bit positions 31 and up may be used for values that are not flag bits,
807    or for <<adding-bitflags, flag bits used with 64-bit flag types>>.
808    Exactly one of attr:value and attr:bitpos must be present in an tag:enum
809    tag.
810  * attr:name - required.
811    Enumerant name, a legal C preprocessor token name.
812  * attr:api - optional <<schema:apiname, API names>> for which this
813    definition is specialized, so that different APIs may have different
814    values for the same token.
815    This definition is only used if the requested API name matches the
816    attribute.
817    May be used to address subtle incompatibilities.
818  * attr:type - may be used only when attr:value is specified.
819    In this case, attr:type is optional except when defining a
820    <<compile-time-constants, compile time constant>>, in which case it is
821    required when using some output generator paths.
822    If present the attribute must be a C scalar type corresponding to the
823    type of attr:value, although only `uint32_t`, `uint64_t`, and `float`
824    are currently meaningful.
825    attr:type is used by some output generators to generate constant
826    declarations, although the default behavior is to use C `#define` for
827    compile-time constants.
828  * attr:alias - optional.
829    Name of another enumerant this is an alias of, used where token names
830    have been changed as a result of profile changes or for consistency
831    purposes.
832    An enumerant alias is simply a different attr:name for the exact same
833    attr:value or attr:bitpos.
834  * attr:protect - optional.
835    An additional preprocessor token used to protect an enum definition.
836
837[NOTE]
838.Note
839====
840In older versions of the schema, attr:type was described as allowing only
841the C integer suffix types `u` and `ull`, which is inconsistent with the
842current definition.
843However, attr:type was not actually used in the registry processing scripts
844or `vk.xml` at the time the current definition was introduced, so this is
845expected to be a benign change.
846====
847
848
849== Contents of tag:enum tags
850
851tag:enum tags have no allowed contents.
852All information is contained in the attributes.
853
854
855[[tag-unused]]
856= Unused Enumerants (tag:unused tag)
857
858Each tag:unused tag defines a range of enumerants which is allocated, but
859not yet assigned to specific enums.
860This just tracks the unused values for the Registrar's use, and is not used
861for header generation.
862
863[NOTE]
864.Note
865====
866tag:unused tags could be generated and inserted automatically, which would
867be a good way to avoid the attributes becoming out of date.
868However, they are rarely used in the Vulkan XML schema, unlike the OpenGL
869XML schema it was based on.
870====
871
872== Attributes of tag:unused tags
873
874  * attr:start - required, attr:end - optional.
875    Integers defining the start and end of an unused range of enumerants.
876    attr:start must be {leq} attr:end.
877    If attr:end is not present, then attr:start defines a single unused
878    enumerant.
879    This range should not exceed the range reserved by the surrounding
880    tag:enums tag.
881  * attr:vendor - optional.
882    String describing the vendor or purposes to whom a reserved range of
883    enumerants is allocated.
884    Usually identical to the attr:vendor attribute of the surrounding
885    attr:enums block.
886  * attr:comment - optional.
887    Arbitrary string (unused).
888
889== Contents of tag:unused tags
890
891None.
892
893
894[[tag-commands]]
895= Command Blocks (tag:commands tag)
896
897The tag:commands tag contains definitions of each of the functions
898(commands) used in the API.
899
900== Attributes of tag:commands tags
901
902  * attr:comment - optional.
903    Arbitrary string (unused).
904
905== Contents of tag:commands tags
906
907Each tag:commands block contains zero or more tag:command tags, in arbitrary
908order (although they are typically ordered by sorting on the command name,
909to improve human readability).
910
911
912[[tag-command]]
913= Commands (tag:command tag)
914
915The tag:command tag contains a structured definition of a single API command
916(function).
917
918== Attributes of tag:command tags
919
920There are two ways to define a command.
921The first uses a set of attributes to the tag:command tag defining
922properties of the command used for constructing automatic validation rules,
923and the contents of the tag:command tag define the name, signature, and
924parameters of the command.
925In this case the allowed attributes include:
926
927  * attr:queues - optional.
928    A string identifying the command queues this command can be placed on.
929    The format of the string is one or more of the terms `"compute"`,
930    `"transfer"`, and `"graphics"`, with multiple terms separated by commas
931    (`","`).
932  * attr:successcodes - optional.
933    A string describing possible successful return codes from the command,
934    as a comma-separated list of Vulkan result code names.
935  * attr:errorcodes - optional.
936    A string describing possible error return codes from the command, as a
937    comma-separated list of Vulkan result code names.
938  * attr:renderpass - optional.
939    A string identifying whether the command can be issued only inside a
940    render pass (`"inside"`), only outside a render pass (`"outside"`), or
941    both (`"both"`).
942  * attr:cmdbufferlevel - optional.
943    A string identifying the command buffer levels that this command can be
944    called by.
945    The format of the string is one or more of the terms `"primary"` and
946    `"secondary"`, with multiple terms separated by commas (`","`).
947  * attr:comment - optional.
948    Arbitrary string (unused).
949
950The second way of defining a command is as an alias of another command.
951For example when an extension is promoted from extension to core status, the
952commands defined by that extensions become aliases of the corresponding new
953core commands.
954In this case, only two attributes are allowed:
955
956  * attr:name - required.
957    A string naming the command defined by the tag.
958  * attr:alias - required.
959    A string naming the command that attr:name is an alias of.
960    The string must be the same as the attr:name value of another
961    tag:command defining another command.
962
963Both forms of tag:command support these options:
964
965  * attr:api - optional <<schema:apiname, API names>> for which this
966    definition is specialized, so that different APIs may have different
967    values for the same token.
968    This definition is only used if the requested API name matches the
969    attribute.
970    May be used to address subtle incompatibilities.
971
972== Contents of tag:command tags
973
974  * tag:proto is required and must be the first element.
975    It is a tag defining the C function prototype of a command as described
976    below, up to the function name and return type but not including
977    function parameters.
978  * tag:param elements for each command parameter follow, defining its name
979    and type, as described below.
980    If a command takes no arguments, it has no tag:param tags.
981
982Following these elements, the remaining elements in a tag:command tag are
983optional and may be in any order:
984
985  * tag:alias - optional.
986    Has no attributes and contains a string which is the name of another
987    command this command is an alias of, used when promoting a function from
988    vendor to Khronos extension or Khronos extension to core API status.
989    A command alias describes the case where there are two function names
990    which implement the same behavior.
991  * tag:description - optional.
992    Unused text.
993  * tag:implicitexternsyncparams - optional.
994    Contains a list of tag:param tags, each containing asciidoc source text
995    describing an object which is not a parameter of the command but is
996    related to one, and which also <<tag-command:param:attr,requires
997    external synchronization>>.
998    The text is intended to be incorporated into the API specification.
999
1000[NOTE]
1001.Note
1002====
1003Versions of the registry documentation prior to 1.1.93 asserted that command
1004aliases "`resolve to the _same_ entry point in the underlying layer stack.`"
1005Whilst this may be true on many implementations, it is not required - each
1006command alias must be queried separately through `vkGetInstanceProcAddr`
1007or `vkGetDeviceProcAddr`.
1008====
1009
1010
1011[[tag-command:proto]]
1012== Command prototype (tag:proto tags)
1013
1014The tag:proto tag defines the return type and name of a command.
1015
1016=== Attributes of tag:proto tags
1017
1018None.
1019
1020// attr:group - group name, an arbitrary string.
1021//
1022// If the group name is defined, it may be interpreted as described in
1023// <<tag-group:meaning>>.
1024
1025=== Contents of tag:proto tags
1026
1027The text elements of a tag:proto tag, with all other tags removed, is legal
1028C code describing the return type and name of a command.
1029In addition to text, it may contain two semantic tags:
1030
1031  * The tag:type tag is optional, and contains text which is a valid type
1032    name found in a tag:type tag.
1033    It indicates that this type must be previously defined for the
1034    definition of the command to succeed.
1035    Builtin C types, and any derived types which are expected to be found in
1036    other header files, should not be wrapped in tag:type tags.
1037  * The tag:name tag is required, and contains the command name being
1038    described.
1039
1040
1041[[tag-command:param]]
1042== Command parameter (tag:param tags)
1043
1044The tag:param tag defines the type and name of a parameter.
1045Its contents are very similar to the tag:member tag used to define struct
1046and union members.
1047
1048
1049[[tag-command:param:attr]]
1050=== Attributes of tag:param tags
1051
1052  * attr:len - if the param is an array, len may be one or more of the
1053    following things, separated by commas (one for each array indirection):
1054    another param of that command; `"null-terminated"` for a string; `"1"`
1055    to indicate it is just a pointer (used for nested pointers); or an
1056    equation in math markup for incorporation in the specification (a LaTeX
1057    math expression delimited by `latexmath:[` and `]`.
1058    The only variables in the equation should be the names of this or other
1059    parameters.
1060  * attr:altlen - if the attr:len attribute is specified, and contains a
1061    `latexmath:` equation, this attribute should be specified with an
1062    equivalent equation using only C builtin operators, C math library
1063    function names, and variables as allowed for attr:len.
1064    It must be a valid C99 expression whose result is equal to attr:len for
1065    all possible inputs.
1066    It is a comma separated list that has size equal to only the `latexmath`
1067    item count in attr:len list.
1068    This attribute is intended to support consumers of the XML who need to
1069    generate validation code from the allowed length.
1070  * attr:optional - optional.
1071    A value of `"true"` or `"false"` determines whether this parameter can
1072    be omitted by providing `NULL` (for pointers), `VK_NULL_HANDLE` (for
1073    handles), or 0 (for other scalar types).
1074    If the parameter is a pointer to one of those types, multiple values may
1075    be provided, separated by commas - one for each pointer indirection.
1076    If not present, the value is assumed to be `"false"` (the parameter must
1077    not be omitted).
1078+
1079--
1080[NOTE]
1081.Note
1082====
1083While the attr:optional attribute can be used for scalar types such as
1084integers, it does not affect the output generators included with the Vulkan
1085Specification.
1086In this case, the attribute serves only as an indicator to human readers of
1087the XML.
1088====
1089--
1090  * attr:selector - optional.
1091    If the parameter is a union, attr:selector identifies another parameter
1092    of the command that is used to select which of that union's members are
1093    valid.
1094  * attr:noautovalidity - prevents automatic validity language being
1095    generated for the tagged item.
1096    Only suppresses item-specific validity - parenting issues etc.
1097    are still captured.
1098  * attr:externsync - optional.
1099    A value of `"true"` indicates that this parameter (e.g. the object a
1100    handle refers to, or the contents of an array a pointer refers to) is
1101    modified by the command, and is not protected against modification in
1102    multiple app threads.
1103    If only certain members of an object or elements of an array are
1104    modified, multiple strings may be provided, separated by commas.
1105    Each string describes a member which is modified.
1106    For example, the `vkQueueSubmit` command includes attr:externsync
1107    attributes for the `pSubmits` array indicating that only specific
1108    members of each element of the array are modified:
1109+
1110--
1111[source,xml]
1112--------------------------------------
1113<param len="submitCount" externsync="pSubmits[].pWaitSemaphores[],pSubmits[].pSignalSemaphores[]">const <type>VkSubmitInfo</type>* <name>pSubmits</name></param>
1114--------------------------------------
1115
1116Parameters which do not have an attr:externsync attribute are assumed to not
1117require external synchronization.
1118--
1119  * attr:objecttype - only applicable for parameters which are `uint64_t`
1120    values representing a Vulkan obejct handle.
1121    Specifies the name of another parameter which must be a `VkObjectType`
1122    or `VkDebugReportObjectTypeEXT` value specifying the type of object the
1123    handle refers to.
1124
1125=== Contents of tag:param tags
1126
1127The text elements of a tag:param tag, with all other tags removed, is legal
1128C code describing the type and name of a function parameter.
1129In addition it may contain two semantic tags:
1130
1131  * The tag:type tag is optional, and contains text which is a valid type
1132    name found in tag:type tag, and indicates that this type must be
1133    previously defined for the definition of the command to succeed.
1134    Builtin C types, and any derived types which are expected to be found in
1135    other header files, should not be wrapped in tag:type tags.
1136  * The tag:name tag is required, and contains the parameter name being
1137    described.
1138
1139== Example of a tag:commands tag
1140
1141[source,xml]
1142--------------------------------------
1143<commands>
1144    <command>
1145        <proto><type>VkResult</type> <name>vkCreateInstance</name></proto>
1146        <param>const <type>VkInstanceCreateInfo</type>* <name>pCreateInfo</name></param>
1147        <param><type>VkInstance</type>* <name>pInstance</name></param>
1148    </command>
1149</commands>
1150--------------------------------------
1151
1152When processed into a C header, this results in
1153
1154[source,c]
1155--------------------------------------
1156VkResult vkCreateInstance(
1157    const VkInstanceCreateInfo* pCreateInfo,
1158    VkInstance* pInstance);
1159--------------------------------------
1160
1161
1162[[tag-feature]]
1163= API Features and Versions (tag:feature tag)
1164
1165API features are described in individual tag:feature tags.
1166A feature is the set of interfaces (enumerants and commands) defined by a
1167particular API and version, such as Vulkan 1.0, and includes all profiles of
1168that API and version.
1169
1170== Attributes of tag:feature tags
1171
1172  * attr:api - required <<schema:apiname, API names>> this feature is
1173    defined for, such as `vulkan`.
1174  * attr:name - required.
1175    Version name, used as the C preprocessor token under which the version's
1176    interfaces are protected against multiple inclusion.
1177    Example: `"VK_VERSION_1_0"`.
1178  * attr:number - required.
1179    Feature version number, usually a string interpreted as
1180    `majorNumber.minorNumber`.
1181    Example: `4.2`.
1182  * attr:sortorder - optional.
1183    A decimal number which specifies an order relative to other tag:feature
1184    tags when calling output generators.
1185    Defaults to `0`.
1186    Rarely used, for when ordering by attr:name is insufficient.
1187  * attr:protect - optional.
1188    An additional preprocessor token used to protect a feature definition.
1189    Usually another feature or extension attr:name.
1190    Rarely used, for odd circumstances where the definition of a feature or
1191    extension requires another to be defined first.
1192  * attr:comment - optional.
1193    Arbitrary string (unused).
1194
1195[NOTE]
1196.Note
1197====
1198The attr:name attribute used for Vulkan core versions, such as
1199`"VK_VERSION_1_0"`, is not an API construct.
1200It is used only as a preprocessor guard in the headers, and an asciidoctor
1201conditional in the specification sources.
1202The similar `"VK_API_VERSION_1_0"` symbols are part of the API and their
1203values are packed integers containing Vulkan core version numbers.
1204====
1205
1206== Contents of tag:feature tags
1207
1208Zero or more <<tag-required,tag:require and tag:remove tags>>, in arbitrary
1209order.
1210Each tag describes a set of interfaces that is respectively required for, or
1211removed from, this feature, as described below.
1212
1213== Example of a tag:feature tag
1214
1215[source,xml]
1216--------------------------------------
1217<feature api="vulkan" name="VK_VERSION_1_0" number="1.0">
1218    <require comment="Header boilerplate">
1219        <type name="vk_platform"/>
1220    </require>
1221    <require comment="API constants">
1222        <enum name="VK_MAX_PHYSICAL_DEVICE_NAME"/>
1223        <enum name="VK_LOD_CLAMP_NONE"/>
1224    </require>
1225    <require comment="Device initialization">
1226        <command name="vkCreateInstance"/>
1227    </require>
1228</feature>
1229--------------------------------------
1230
1231When processed into a C header for Vulkan, this results in:
1232
1233[source,c]
1234--------------------------------------
1235#ifndef VK_VERSION_1_0
1236#define VK_VERSION_1_0 1
1237#define VK_MAX_EXTENSION_NAME   256
1238#define VK_LOD_CLAMP_NONE       MAX_FLOAT
1239typedef VkResult (VKAPI_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance);
1240#ifndef VK_NO_PROTOTYPES
1241VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
1242    const VkInstanceCreateInfo*                 pCreateInfo,
1243    VkInstance*                                 pInstance);
1244#endif
1245#endif /* VK_VERSION_1_0 */
1246--------------------------------------
1247
1248
1249[[tag-extensions]]
1250= Extension Blocks (tag:extensions tag)
1251
1252The tag:extensions tag contains definitions of each of the extensions which
1253are defined for the API.
1254
1255== Attributes of tag:extensions tags
1256
1257  * attr:comment - optional.
1258    Arbitrary string (unused).
1259
1260== Contents of tag:extensions tags
1261
1262Each tag:extensions block contains zero or more tag:extension tags, each
1263describing an API extension, in arbitrary order (although they are typically
1264ordered by sorting on the extension name, to improve human readability).
1265
1266
1267[[tag-extension]]
1268= API Extensions (tag:extension tag)
1269
1270API extensions are described in individual tag:extension tags.
1271An extension is the set of interfaces defined by a particular API extension
1272specification, such as `ARB_multitexture`.
1273tag:extension is similar to tag:feature, but instead of having an
1274attr:number attribute, it instead has a attr:supported attribute, which
1275describes the set of API names which the extension can potentially be
1276implemented against.
1277
1278== Attributes of tag:extension tags
1279
1280  * attr:name - required.
1281    Extension name, following the conventions in the Vulkan Specification.
1282    Example: `name="VK_VERSION_1_0"`.
1283  * attr:number - required.
1284    A decimal number which is the registered, unique extension number for
1285    attr:name.
1286  * attr:sortorder - optional.
1287    A decimal number which specifies an order relative to other
1288    tag:extension tags when calling output generators.
1289    Defaults to `0`.
1290    Rarely used, for when ordering by attr:number is insufficient.
1291  * attr:author - optional.
1292    The author name, such as a full company name.
1293    If not present, this can be taken from the corresponding tag:tag
1294    attribute.
1295    However, `EXT` and other multi-vendor extensions may not have a
1296    well-defined author or contact in the tag.
1297    This attribute is not used in processing the XML.
1298    It is just metadata, mostly used to track the original author of an
1299    extension (which may have since been promoted to use a different author
1300    ID).
1301  * attr:contact - optional.
1302    The contact who registered or is currently responsible for extensions
1303    and layers using the tag, including sufficient contact information to
1304    reach the contact such as individual name together with Github username
1305    (`@username`), Khronos internal Gitlab username (`gitlab:@username`) if
1306    no public Github contact is available, or other contact information.
1307    If not present, this can be taken from the corresponding tag:tag
1308    attribute just like attr:author.
1309  * attr:type - required if the attr:supported attribute is not
1310    `'disabled'`.
1311    Must be either `'device'` or `'instance'`, if present.
1312  * attr:requires - optional.
1313    Comma-separated list of extension names this extension requires to be
1314    supported.
1315    Extensions whose attr:type is `'instance'` must not require extensions
1316    whose attr:type is `'device'`.
1317  * attr:requiresCore - optional.
1318    Core version of Vulkan required by the extension, e.g. "1.1".
1319    Defaults to "1.0".
1320  * attr:protect - optional.
1321    An additional preprocessor token used to protect an extension
1322    definition.
1323    Usually another feature or extension attr:name.
1324    Rarely used, for odd circumstances where the definition of an extension
1325    requires another extension or a header file to be defined first.
1326  * attr:platform - optional.
1327    Indicates that the extension is specific to the platform identified by
1328    the attribute value, and should be emitted conditional on that platform
1329    being available, in a platform-specific header, etc.
1330    The attribute value must be the same as one of the tag:platform tag:name
1331    attribute values.
1332  * attr:supported - required <<schema:apiname, API names>> this extension
1333    is defined for.
1334    When the extension tag is just reserving an extension number, use
1335    `supported="disabled"` to indicate this extension should never be
1336    processed.
1337    Interfaces defined in a `disabled` extension block are tentative at best
1338    and must: not be generated or otherwise used by scripts processing the
1339    XML.
1340    The only exception to this rule is for scripts used solely for
1341    reserving, or checking for reserved bitflag values.
1342  * attr:promotedto - optional.
1343    A Vulkan version or a name of an extension that this extension was
1344    _promoted_ to.
1345    E.g. `"VK_VERSION_1_1"`, or `"VK_KHR_draw_indirect_count"`.
1346  * attr:deprecatedby - optional.
1347    A Vulkan version or a name of an extension that _deprecates_ this
1348    extension.
1349    It may be an empty string.
1350    E.g. `"VK_VERSION_1_1"`, or `"VK_EXT_debug_utils"`, or `""`.
1351  * attr:obsoletedby - optional.
1352    A Vulkan version or a name of an extension that _obsoletes_ this
1353    extension.
1354    It may be an empty string.
1355    E.g. `"VK_VERSION_1_1"`, or `"VK_KHR_maintenance1"`, or `""`.
1356  * attr:provisional - optional.
1357    'true' if this extension is released provisionally.
1358  * attr:specialuse - optional.
1359    If present, must contain one or more tokens separated by commas,
1360    indicating a special purpose of the extension.
1361    Tokens may include:
1362  ** 'cadsupport' - for support of CAD software.
1363  ** 'd3demulation' - for support of Direct3D emulation layers or libraries,
1364     or applications porting from Direct3D.
1365  ** 'debugging' - for debugging an application.
1366  ** 'devtools' - for support of developer tools, such as capture-replay
1367     libraries.
1368  ** 'glemulation' - for support of OpenGL and/or OpenGL ES emulation layers
1369     or libraries, or applications porting from those APIs.
1370  * attr:comment - optional.
1371    Arbitrary string (unused).
1372
1373
1374[NOTE]
1375.Note
1376====
1377The attr:requires attribute is used to specify other extensions that *must*
1378be enabled for an extension to be enabled.
1379
1380In some cases, an extension may include functionality which is only defined
1381*if* another extension is enabled.
1382Such functionality should be specified within a tag:require, using the
1383attr:extension attribute to specify that extension.
1384====
1385
1386== Contents of tag:extension tags
1387
1388Zero or more <<tag-required,tag:require and tag:remove tags>>, in arbitrary
1389order.
1390Each tag describes a set of interfaces that is respectively required for, or
1391removed from, this extension, as described below.
1392
1393== Example of an tag:extensions tag
1394
1395[source,xml]
1396--------------------------------------
1397<extension name="VK_KHR_display_swapchain" number="4" supported="vulkan">
1398    <require>
1399        <enum value="9" name="VK_KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION"/>
1400        <enum value="4" name="VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NUMBER"/>
1401        <enum value="&quot;VK_KHR_display_swapchain&quot;"
1402              name="VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME"/>
1403        <type name="VkDisplayPresentInfoKHR"/>
1404        <command name="vkCreateSharedSwapchainsKHR"/>
1405    </require>
1406</extension>
1407--------------------------------------
1408
1409The attr:supported attribute says that the extension is defined for the
1410default profile (`vulkan`).
1411When processed into a C header for the `vulkan` profile, this results in
1412header contents something like (assuming corresponding definitions of the
1413specified tag:type and tag:command elsewhere in the XML):
1414
1415[source,c]
1416--------------------------------------
1417#define VK_KHR_display_swapchain 1
1418#define VK_KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION 9
1419#define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NUMBER 4
1420#define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME "VK_KHR_display_swapchain"
1421
1422typedef struct VkDisplayPresentInfoKHR {
1423    VkStructureType                             sType;
1424    const void*                                 pNext;
1425    VkRect2D                                    srcRect;
1426    VkRect2D                                    dstRect;
1427    VkBool32                                    persistent;
1428} VkDisplayPresentInfoKHR;
1429
1430typedef VkResult (VKAPI_PTR *PFN_vkCreateSharedSwapchainsKHR)(
1431    VkDevice device, uint32_t swapchainCount,
1432    const VkSwapchainCreateInfoKHR* pCreateInfos,
1433    const VkAllocationCallbacks* pAllocator,
1434    VkSwapchainKHR* pSwapchains);
1435
1436#ifndef VK_NO_PROTOTYPES
1437VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR(
1438    VkDevice                                    device,
1439    uint32_t                                    swapchainCount,
1440    const VkSwapchainCreateInfoKHR*             pCreateInfos,
1441    const VkAllocationCallbacks*                pAllocator,
1442    VkSwapchainKHR*                             pSwapchains);
1443#endif
1444--------------------------------------
1445
1446
1447[[tag-required]]
1448= Required and Removed Interfaces (tag:require and tag:remove tags)
1449
1450A tag:require block defines a set of interfaces (types, enumerants and
1451commands) 'required' by a tag:feature or tag:extension.
1452A tag:remove block defines a set of interfaces 'removed' by a tag:feature.
1453This is primarily for future profiles of an API which may choose to
1454deprecate and/or remove some interfaces.
1455Extensions should never remove interfaces, although this usage is allowed by
1456the schema).
1457Except for the tag name and behavior, the contents of tag:require and
1458tag:remove tags are identical.
1459
1460== Attributes of tag:require and tag:remove tags
1461
1462  * attr:profile - optional.
1463    String name of an API profile.
1464    Interfaces in the tag are only required (or removed) if the specified
1465    profile is being generated.
1466    If not specified, interfaces are required (or removed) for all API
1467    profiles.
1468  * attr:comment - optional.
1469    Arbitrary string (unused).
1470  * attr:api - optional <<schema:apiname, API names>> requiring or removing
1471    these interfaces.
1472    Interfaces in the tag are only required (or removed) if the requested
1473    API name matches the attribute.
1474    If not specified, interfaces are required (or removed) for all APIs.
1475
1476[NOTE]
1477.Note
1478====
1479The attr:api attribute is only supported inside tag:extension tags, since
1480tag:feature tags already define a specific API.
1481====
1482
1483== Attributes of tag:require tags
1484
1485These attribues are allowed only for a tag:require tag.
1486
1487  * attr:extension - optional, and only for tag:require tags.
1488    String containing an API extension name.
1489    Interfaces in the tag are only required if the string matches the
1490    attr:name of an tag:extension tag, and that extension is enabled.
1491  * attr:feature - optional, and only for tag:require tags.
1492    String containing an API feature name.
1493    Interfaces in the tag are only required if the string matches the
1494    attr:name of a tag:feature tag, and that feature is enabled.
1495
1496[NOTE]
1497.Note
1498====
1499The attr:extension attribute currently does not affect output generators in
1500any way, and is simply metadata.
1501This will be addressed as we better define different types of dependencies
1502between extensions.
1503====
1504
1505== Contents of tag:require and tag:remove tags
1506
1507Zero or more of the following tags, in any order:
1508
1509=== Comment Tags
1510
1511<<tag-comment, tag:comment>> (as described above).
1512
1513=== Command Tags
1514
1515tag:command specifies an required (or removed) command defined in a
1516tag:commands block.
1517The tag has no content, but contains attributes:
1518
1519  * attr:name - required.
1520    Name of the command.
1521  * attr:comment - optional.
1522    Arbitrary string (unused).
1523
1524=== Enum tags
1525
1526tag:enum specifies an required (or removed) enumerant defined in a tag:enums
1527block.
1528All forms of this tag support the following attributes:
1529
1530  * attr:name - required.
1531    Name of the enumerant.
1532  * attr:comment - optional.
1533    Arbitrary string (unused).
1534  * attr:api - optional <<schema:apiname, API names>> for which this
1535    definition is specialized, so that different APIs may have different
1536    values for the same token.
1537    This definition is only used if the requested API name matches the
1538    attribute.
1539    May be used to address subtle incompatibilities.
1540
1541There are two forms of tag:enum tags:
1542
1543_Reference enums_ simply pull in the definition of an enumerant given in a
1544separate tag:enums block.
1545No attributes other than attr:name and attr:comment are supported for them.
1546tag:enum tags appearing inside tag:remove tags should always be reference
1547enums.
1548Reference enums may also be used inside tag:require tags, if the
1549corresponding value is defined in a tag:enums block.
1550This is typically used for constants not part of an enumerated type.
1551
1552_Extension enums_ define the value of an enumerant inline in an tag:feature
1553or tag:extensions block.
1554Typically these are used to add additional values specified by an extension
1555or core feature to an existing enumerated type.
1556There are a variety of attributes which are used to specify the value of the
1557enumerant:
1558
1559  * attr:value and attr:type - define a constant value in the same fashion
1560    as an tag:enum tag in an <<tag-enum,tag:enums>> block.
1561  * attr:bitpos - define a constant bitmask value in the same fashion as an
1562    <<tag-enum,tag:enum>> tag in an tag:enums block.
1563    attr:bitpos is a literal integer bit position in a bitmask.
1564    The same value and usage constraints apply to this bit position as are
1565    applied to the <<tag-enum, attr:bitpos attribute of an tag:enum tag.
1566  * attr:extends - the name of a separately defined enumerated type (e.g. a
1567    tag:type tag with attr:category``="enum"``) to which the extension
1568    enumerant is added.
1569    The enumerated type is required to complete the definition of the
1570    enumerant, in the same fashion as the attr:requires attribute of a
1571    tag:type tag.
1572    If not present, the enumerant is treated as a global constant value.
1573  * attr:extnumber - an extension number.
1574    The extension number in turn specifies the starting value of a block
1575    (range) of values reserved for enumerants defined by or associated with
1576    the corresponding tag:extension tag with the same attr:number.
1577    This is used when an extension or core feature needs to extend an
1578    enumerated type in a block defined by a different extension.
1579  * Attribute attr:offset - the offset within an extension block.
1580    If attr:extnumber is not present, the extension number defining that
1581    block is given by the attr:number attribute of the surrounding
1582    tag:extension tag.
1583    The actual numeric value of the enumerant is computed as defined in the
1584    "`Layers and Extensions`" appendix of the Vulkan Specification.
1585  * Attribute attr:dir - if present, the calculated enumerant value will be
1586    negative, instead of positive.
1587    Negative enumerant values are normally used only for Vulkan error codes.
1588    The attribute value must be specified as `dir="-"`.
1589  * attr:alias - the name of another enumerant this is an alias of.
1590    An enumerant alias is simply a different name for the same enumerant
1591    value.
1592    This is typically used when promoting an enumerant defined by an
1593    extension to a new core version of the API.
1594    The old extension enumerant is still defined, but as an alias of the new
1595    core enumerant.
1596    It may also be used when token names have been changed as a result of
1597    profile changes, or for consistency purposes.
1598  * attr:protect - define a preprocessor protection symbol for the enum in
1599    the same fashion as a tag:enum tag in an <<tag-enum,tag:enums>> block.
1600
1601Not all combinations of attributes are either meaningful or supported.
1602The attr:protect attribute may always be present.
1603For other attributes, the allowed combinations are:
1604
1605.Valid Combinations of attr:enum Attributes for Extension Enums
1606|====
1607| attr:value | attr:bitpos | attr:alias | attr:offset | attr:extnumber | attr:dir | attr:extends | Description
1608| {yes}      | {no}        | {no}       | {no}        | {no}           | {no}     | {opt}^2^     | Numeric value
1609| {no}       | {yes}       | {no}       | {no}        | {no}           | {no}     | {opt}^2^     | Bitmask value
1610| {no}       | {no}        | {yes}      | {no}        | {no}           | {no}     | {opt}^2^     | Alias of another enumerant
1611| {no}       | {no}        | {no}       | {yes}       | {opt}^1^       | {opt}    | {yes}        | Value added to an enumeration
1612| {no}       | {no}        | {no}       | {yes}       | {opt}^1^       | {opt}    | {yes}        | Value added to an enumeration
1613|====
1614
1615[1]: If attr:extnumber is not present, the tag:enum tag may only be within a
1616tag:extension.
1617Otherwise, the tag:enum tag may also be within a tag:feature.
1618
1619[2]: If attr:extends is not present, the enumerant value is a global
1620constant.
1621Otherwise, the value is added to the specified enumeration.
1622
1623Examples of <<tag-required-examples,various types of extension enumerants>>
1624are given below.
1625
1626
1627=== Type tags
1628
1629tag:type specifies a required (or removed) type defined in a tag:types
1630block.
1631Most types are picked up implicitly by using the tag:type tags of commands,
1632but in a few cases, additional types need to be specified explicitly.
1633It is unlikely that a type would ever be removed, although this usage is
1634allowed by the schema.
1635The tag has no content, but contains elements:
1636
1637  * attr:name - required.
1638    Name of the type.
1639  * attr:comment - optional.
1640    Arbitrary string (unused).
1641
1642
1643[[tag-required-examples]]
1644== Examples of Extension Enumerants
1645
1646Examples of some of the supported extension enumerant tag:enum tags are
1647given below.
1648
1649[source,xml]
1650--------------------------------------
1651<extensions>
1652    <extension name="VK_KHR_test_extension" number="1" supported="vulkan">
1653        <require>
1654            <enum value="42" name="VK_KHR_TEST_ANSWER"/>
1655            <enum bitpos="29" name="VK_KHR_TEST_BITMASK"/>
1656            <enum offset="0" dir="-" extends="VkResult"
1657                  name="VK_ERROR_SURFACE_LOST_KHR"/>
1658            <enum offset="1" extends="VkResult"
1659                  name="VK_SUBOPTIMAL_KHR"/>
1660            <enum bitpos="30" extends="VkCullModeFlagBits"
1661                  name="VK_KHR_TEST_CULL_MODE_BIT"/>
1662        </require>
1663    </extension>
1664</extensions>
1665--------------------------------------
1666
1667The corresponding header file will include definitions like this:
1668
1669[source,c]
1670--------------------------------------
1671typedef enum VkResult {
1672    <previously defined VkResult enumerant values},
1673    VK_ERROR_SURFACE_LOST_KHR = -1000000000,
1674    VK_SUBOPTIMAL_KHR = 1000000001,
1675    VK_KHR_EXTENSION_BIT = 0x80000000,
1676};
1677
1678#define VK_KHR_test_extension 1
1679#define VK_KHR_theanswer 42
1680#define VK_KHR_bitmask 0x20000000
1681--------------------------------------
1682
1683
1684[[tag-formats]]
1685= Formats (tag:formats tag)
1686
1687The tag:formats tag contains definitions of each of the image formats which
1688are defined for the API.
1689
1690== Attributes of tag:formats tags
1691
1692None.
1693
1694//  * attr:comment - optional.
1695//    Arbitrary string (unused).
1696
1697== Contents of tag:formats tags
1698
1699A tag:formats block contains zero or more tag:format tags, each describing
1700an image format, in arbitrary order.
1701
1702
1703[[tag-format]]
1704= Image Format (tag:format tag)
1705
1706Image formats are described in individual tag:format tags.
1707An image format corresponds to a Vulkan `VkFormat` enumerant.
1708This tag contains information specifying the structure and meaning of
1709different parts of the format.
1710The meaning of different parts of the format information is described in
1711more detail in the "`Format Definition`" section of the Vulkan API
1712Specification.
1713
1714== Attributes of tag:format tags
1715
1716  * attr:name - required.
1717    Format name, matching a `VkFormat` tag:enum attr:name.
1718    Example: `name="VK_FORMAT_R8_UNORM"`.
1719  * attr:class - required.
1720    Format class.
1721    A string whose value is shared by a group of formats which may be
1722    compatible, and is a textual description of something important that
1723    group has in common.
1724    Example: `class="8-bit"`.
1725  * attr:blockSize - required.
1726    A decimal integer which is the texel block size, in bytes, of the
1727    format.
1728  * attr:texelsPerBlock - required
1729    A decimal integer which is the number of texels in a texel block of the
1730    format.
1731  * attr:blockExtent - optional.
1732    Three-dimensional extent of a texel block.
1733    A comma-separated list of three decimal integers.
1734    If not present, `blockExtent="1,1,1"` is assumed.
1735  * attr:packed - optional.
1736    A decimal integer which is the number of bits into which the format is
1737    packed.
1738    If defined, a single image element in this format can be stored in the
1739    same space as a scalar type of this bit width.
1740  * attr:compressed - optional.
1741    A string whose value is shared by a group of formats which use the same
1742    general texture compression scheme, and is a textual description of that
1743    scheme.
1744    Example: `compressed="ASTC LDR"`.
1745  * attr:chroma - optional.
1746    A string used to mark if {YCbCr} samplers are required by default when
1747    using this format.
1748    Must be one of the three values `"420"`, `"422"`, or `"444"`
1749    corresponding to different {YCbCr} encodings.
1750
1751== Contents of tag:format tags
1752
1753One or more <<tag-component,tag:component>> tags.
1754The order of tag:component tags corresponds to the memory order of
1755components of the format.
1756Each tag describes the size and format of that component.
1757
1758Zero or more <<tag-plane,tag:plane>> tags, in arbitrary order.
1759Each tag describes the scale of a specific image plane of the format
1760relative to the overall format.
1761
1762Zero or more <<tag-spirvimageformat,tag:spirvimageformat>> tags, in
1763arbitrary order.
1764Each tag describes a SPIR-V format name corresponding to the tag:format.
1765
1766== Example of a tag:format tag
1767
1768[source,xml]
1769--------------------------------------
1770<format name="VK_FORMAT_G16_B16R16_2PLANE_420_UNORM" class="16-bit 2-plane 420" blockSize="6" texelsPerBlock="1" chroma="420">
1771    <component name="G" bits="16" numericFormat="UNORM" planeIndex="0"/>
1772    <component name="B" bits="16" numericFormat="UNORM" planeIndex="1"/>
1773    <component name="R" bits="16" numericFormat="UNORM" planeIndex="1"/>
1774    <plane index="0" widthDivisor="1" heightDivisor="1" compatible="VK_FORMAT_R16_UNORM"/>
1775    <plane index="1" widthDivisor="2" heightDivisor="2" compatible="VK_FORMAT_R16G16_UNORM"/>
1776</format>
1777--------------------------------------
1778
1779
1780[[tag-component]]
1781= Format Components (tag:component tag)
1782
1783The tag:component tag contains definitions of each of the components which
1784are part of an image format.
1785
1786== Attributes of tag:component tags
1787
1788  * attr:name - required.
1789    A string specifying the name of this component.
1790    Must be one of the values `"R"`, `"G"`, `"B"`, `"A"`, `"S"`, or `"D"`
1791    corresponding to red, green, blue, alpha, depth, and stencil components,
1792    respectively.
1793  * attr:bits - required.
1794    Must be either a decimal integer which is the number of bits in this
1795    component, or `"compressed"`, corresponding to a specific compression
1796    scheme.
1797  * attr:numericFormat - required.
1798    A string specifying the scalar data type of the component.
1799    Must be one of the following values:
1800  ** `"SFLOAT"` - signed floating-point numbers
1801  ** `"SINT"` - signed integer values in the range [-2^n-1^,2^n-1^-1]
1802  ** `"SNORM"` - signed normalized values in the range [-1,1]
1803  ** `"SRGB"` - R, G, and B components are unsigned normalized values that represent values using sRGB nonlinear encoding, while the A component (if one exists) is a regular unsigned normalized value
1804  ** `"SSCALED"` - signed integer values that get converted to floating-point in the range [-2^n-1^,2^n-1^-1]
1805  ** `"UFLOAT"` - unsigned floating-point numbers (used by packed, shared exponent, and some compressed formats)
1806  ** `"UINT"` - unsigned integer values in the range [0,2^n^-1]
1807  ** `"UNORM"` - unsigned normalized values in the range [0,1]
1808  ** `"USCALED"` - unsigned integer values that get converted to floating-point in the range [0,2^n^-1]
1809  * attr:planeIndex - optional.
1810    A decimal integer specifying which plane this component lies in.
1811    If present, must correspond to the attr:index attribute value of a
1812    tag:plane tag for the same tag:component.
1813
1814== Contents of tag:component tags
1815
1816None.
1817
1818
1819[[tag-plane]]
1820= Format Planes (tag:plane tag)
1821
1822The tag:plane tag contains definitions of each of the image planes which are
1823part of an image format.
1824
1825== Attributes of tag:plane tags
1826
1827  * attr:index - required.
1828    An integer specifying the image plane being defined.
1829    Image planes are in the range [0,_p_-1] where _p_ is the number of
1830    planes in the format.
1831  * attr:widthDivisor - required.
1832    An integer specifying the relative width of this plane.
1833    A value of _k_ means that this plane is 1/_k_ the width of the overall
1834    format.
1835  * attr:heightDivisor - required.
1836    An integer specifying the relative height of this plane.
1837    A value of _k_ means that this plane is 1/_k_ the height of the overall
1838    format.
1839  * attr:compatible - required.
1840    A string naming another, single-plane format that this plane is
1841    compatible with.
1842    Must match the attr:name of another attr:format.
1843
1844== Contents of tag:plane tags
1845
1846None.
1847
1848
1849[[tag-spirvimageformat]]
1850= SPIR-V Image Formats (tag:spirvimageformat tag)
1851
1852The tag:spirvimageformat tag specifies the name of a SPIR-V image format
1853equivalent to this format.
1854
1855== Attributes of tag:spirvimageformat tags
1856
1857  * attr:name - required.
1858    The name of the SPIR-V image format.
1859    Example: `name="R11fG11fB10f"`.
1860
1861== Contents of tag:spirvimageformat tags
1862
1863None.
1864
1865
1866[[tag-spirvextensions]]
1867= SPIR-V Extensions (tag:spirvextensions tag)
1868
1869The tag:spirvextensions tag contains definitions of each of the SPIR-V
1870extensions which are defined for the API.
1871
1872== Attributes of tag:spirvextensions tags
1873
1874  * attr:comment - optional.
1875    Arbitrary string (unused).
1876
1877== Contents of tag:spirvextensions tags
1878
1879Each tag:spirvextensions block contains zero or more tag:spirvextension tags, each
1880describing an single SPIR-V extension, in arbitrary order.
1881
1882
1883[[tag-spirvextension]]
1884= SPIR-V Extension (tag:spirvextension tag)
1885
1886SPIR-V extensions are described in individual tag:spirvextension tags.
1887A SPIR-V extension is enabled by API versions or extensions.
1888
1889== Attributes of tag:spirvextension tags
1890
1891  * attr:name - required.
1892    SPIR-V extension name.
1893    Example: `name="SPV_KHR_variable_pointers"`
1894
1895== Contents of tag:spirvextension tags
1896
1897One or more <<tag-spirvenable,tag:enable>> tags, in arbitrary order.
1898Each tag describes a single enabling mechanism for the extension.
1899
1900== Example of a tag:spirvextensions tag
1901
1902[source,xml]
1903--------------------------------------
1904<spirvextension name="SPV_KHR_multiview">
1905    <enable version="VK_VERSION_1_1"/>
1906    <enable extension="VK_KHR_multiview"/>
1907</spirvextension>
1908--------------------------------------
1909
1910
1911[[tag-spirvcapabilities]]
1912= SPIR-V Capabilities (tag:spirvcapabilities tag)
1913
1914The tag:spirvcapabilities tag contains definitions of each of the SPIR-V
1915capabilities which are defined for the API.
1916
1917== Attributes of tag:spirvcapabilities tags
1918
1919  * attr:comment - optional.
1920    Arbitrary string (unused).
1921
1922== Contents of tag:spirvcapabilities tags
1923
1924Each tag:spirvcapabilities block contains zero or more tag:spirvcapability
1925tags, each describing an single SPIR-V capability, in arbitrary order.
1926
1927
1928[[tag-spirvcapability]]
1929= SPIR-V Capability (tag:spirvcapability tag)
1930
1931SPIR-V capabilities are described in individual tag:spirvcapability tags.
1932A SPIR-V capability is enabled by API versions, extensions, features, or
1933properties.
1934
1935== Attributes of tag:spirvcapability tags
1936
1937  * attr:name - required.
1938    SPIR-V capability name.
1939    Example: `name="SPV_KHR_variable_pointers"`
1940
1941== Contents of tag:spirvcapability tags
1942
1943One or more <<tag-spirvenable,tag:enable>> tags, in arbitrary order.
1944Each tag describes a single enabling mechanism for the capability.
1945
1946== Example of a tag:spirvcapabilities tag
1947
1948[source,xml]
1949--------------------------------------
1950<spirvcapability name="ImageCubeArray">
1951    <enable struct="VkPhysicalDeviceFeatures" feature="imageCubeArray" requires="VK_VERSION_1_0"/>
1952</spirvcapability>
1953<spirvcapability name="GroupNonUniform">
1954    <enable property="VkPhysicalDeviceVulkan11Properties" member="subgroupSupportedOperations" value="VK_SUBGROUP_FEATURE_BASIC_BIT" requires="VK_VERSION_1_1"/>
1955</spirvcapability>
1956--------------------------------------
1957
1958
1959[[tag-spirvenable]]
1960= SPIR-V Enables (tag:enable tag)
1961
1962The tag:enable tag describes a single mechanism in the API which enables a
1963tag:spirvextension or tag:spirvcapability.
1964There are four forms of tag:enable tags corresponding to different ways the
1965API may advertise enablement, though not all forms may be used with
1966tag:spirvextension tags.
1967Each form is described separately below.
1968
1969== Attributes for API Version Number Enables
1970
1971  * attr:version - required.
1972    An API feature name, matching a tag:feature attr:name attribute value.
1973
1974If the API version is supported, the SPIR-V extension or capability is
1975enabled.
1976
1977== Attributes for API Extension Enables
1978
1979  * attr:extension - required.
1980    An API extension name, matching an tag:extension attr:name attribute
1981    value.
1982
1983If the API extension is supported and enabled, the SPIR-V extension or
1984capability is enabled.
1985
1986== Attributes for API Feature Enables
1987
1988  * attr:struct - required.
1989    An API feature structure name, matching a tag:struct attr:name attribute
1990    value.
1991  * attr:feature - required.
1992    An API feature name, matching a tag:member tag:name value of the feature
1993    structure.
1994  * attr:requires - required.
1995    A comma-separated list of API feature version numbers and/or extension
1996    names.
1997  * attr:alias - optional.
1998    Another API feature name which is an alias of attr:feature.
1999    Needed when the same feature is provided by two different API versions
2000    or extensions.
2001
2002If one of the API feature version numbers or extensions in the attr:requires
2003list is supported or enabled, respectively; and if the attr:feature name is
2004enabled in the feature structure, the SPIR-V capability is enabled.
2005
2006API feature enables are not supported for tag:spirvextension tags.
2007
2008== Attributes for API Property Enables
2009
2010  * attr:property - required.
2011    An API property structure name, matching a tag:struct attr:name
2012    attribute value.
2013  * attr:member - required.
2014    An API property name, matching a tag:member tag:name value of the
2015    attr:property structure.
2016  * attr:value - required.
2017    A value, matching an API tag:enum tag:name value.
2018    If the property is a bitfield, tag:value must be a bitmask value
2019    belonging to the attr:member bitfield type.
2020    Otherwise, tag:value must be an tag:enum name defined for the
2021    attr:member enumeration type.
2022  * attr:requires - optional.
2023    A comma-separated list of API feature version numbers and/or extension
2024    names.
2025
2026If one of the API feature version numbers or extensions in the attr:requires
2027list is supported or enabled, respectively; and if the attr:member property
2028contains the tag:value bit, or matches the tag:value, the SPIR-V capability
2029is enabled.
2030
2031API property enables are not supported for tag:spirvextension tags.
2032
2033== Contents of tag:enable tags
2034
2035None.
2036
2037
2038[[examples]]
2039= Examples / FAQ / How Do I?
2040
2041For people new to the Registry, it will not be immediately obvious how to
2042make changes.
2043This section includes some tips and examples that will help you make changes
2044to the Vulkan headers by changing the Registry XML description.
2045
2046First, follow the steps described to <<starting,get the Vulkan Github
2047repository>> containing the registry and assemble the tools necessary to
2048work with the XML registry.
2049Once you are able to regenerate the Vulkan headers from `vk.xml`, you can
2050start making changes.
2051
2052
2053== General Strategy
2054
2055If you are _adding_ to the API, perform the following steps to _create_ the
2056description of that API element:
2057
2058  * For each type, enum group, compile time constant, and command being
2059    added, create appropriate new tag:type, tag:enums, tag:enum, or
2060    tag:command tags defining the interface in question.
2061  * Make sure that all added types and commands appropriately tag their
2062    dependencies on other types by adding nested tag:type tags.
2063  * Make sure that each new tag defines the name of the corresponding type,
2064    enum group, constant, or command, and that structure/union types and
2065    commands tag the types and names of all their members and parameters.
2066    This is essential for the automatic dependency process to work.
2067
2068If you are _modifying_ existing APIs, just make appropriate changes in the
2069existing tags.
2070
2071Once the definition is added, proceed to the next section to create
2072dependencies on the changed feature.
2073
2074
2075== API Feature Dependencies
2076
2077When you add new API elements, they will not result in corresponding changes
2078in the generated header unless they are _required_ by the interface being
2079generated.
2080This makes it possible to include different API versions and extensions in a
2081single registry and pull them out as needed.
2082So you must introduce a dependency on new features in the corresponding
2083tag:feature tag.
2084
2085Initially, the only API feature is Vulkan 1.0, so there is only one
2086tag:feature tag in `vk.xml`.
2087You can find it by searching for the following block of `vk.xml`:
2088
2089[source,xml]
2090--------------------------------------
2091<comment>
2092<feature api="vulkan" name="VK_VERSION_1_0" number="1.0"
2093         comment="Vulkan core API interface definitions">
2094--------------------------------------
2095
2096Inside the tag:feature tag are nested multiple tag:require tags.
2097These are just being used as a logical grouping mechanism for related parts
2098of Vulkan 1.0 at present, though they may have more meaningful roles in the
2099future if different API profiles are defined.
2100
2101
2102=== API Feature Walkthrough
2103
2104This section walks through the first few required API features in the
2105`vk.xml` tag:feature tag, showing how each requirement pulls in type, token,
2106and command definitions and turns those into definitions in the C header
2107file `vulkan_core.h`.
2108
2109Consider the first few lines of the tag:feature:
2110
2111[source,xml]
2112--------------------------------------
2113<require comment="Header boilerplate">
2114    <type name="vk_platform"/>
2115</require>
2116<require comment="API constants">
2117    <enum name="VK_MAX_PHYSICAL_DEVICE_NAME"/>
2118    <enum name="VK_MAX_EXTENSION_NAME"/>
2119    ...
2120</require>
2121<require comment="Device initialization">
2122    <command name="vkCreateInstance"/>
2123    ...
2124--------------------------------------
2125
2126The first tag:require block says to require a type named `vk_platform`.
2127If you look at the beginning of the tag:types section, there is a
2128corresponding definition section:
2129
2130[source,xml]
2131--------------------------------------
2132<type name="vk_platform">#include "vk_platform.h"
2133#define VK_MAKE_VERSION(major, minor, patch) \
2134    ((major &lt;&lt; 22) | (minor &lt;&lt; 12) | patch)
2135    ...
2136--------------------------------------
2137
2138This section is invoked by the requirement and emits a bunch of boilerplate
2139C code.
2140The explicit dependency is not strictly required since `vk_platform` will be
2141required by many other types, but placing it first causes this to appear
2142first in the output file.
2143
2144Note that `vk_platform` does not correspond to an actual C type, but instead
2145to a collection of freeform preprocessor includes and macros and comments.
2146Most other tag:type tags do define a specific type and are much simpler, but
2147this approach can be used to inject arbitrary C into the Vulkan headers
2148*when there is no other way*.
2149In general inserting arbitrary C is strongly discouraged outside of specific
2150special cases like this.
2151
2152The next tag:require block pulls in some compile time constants.
2153These correspond to the definitions found in the first tag:enums section of
2154`vk.xml`:
2155
2156[source,xml]
2157--------------------------------------
2158<enums name="API Constants"
2159       comment="Vulkan hardcoded constants - not an enumerated type, part of the header boilerplate">
2160    <enum value="256"        name="VK_MAX_PHYSICAL_DEVICE_NAME"/>
2161    <enum value="256"        name="VK_MAX_EXTENSION_NAME"/>
2162    ...
2163--------------------------------------
2164
2165The third tag:require block starts pulling in some Vulkan commands.
2166The first command corresponds to the following definition found in the
2167tag:commands section of `vk.xml`:
2168
2169[source,xml]
2170--------------------------------------
2171<commands>
2172    <command>
2173        <proto><type>VkResult</type> <name>vkCreateInstance</name></proto>
2174        <param>const <type>VkInstanceCreateInfo</type>* <name>pCreateInfo</name></param>
2175        <param><type>VkInstance</type>* <name>pInstance</name></param>
2176    </command>
2177    ...
2178--------------------------------------
2179
2180In turn, the tag:command tag requires the tag:types `VkResult`,
2181`VkInstanceCreateInfo`, and `VkInstance` as part of its definition.
2182The definitions of these types are determined as follows:
2183
2184For `VkResult`, the corresponding required tag:type is:
2185
2186[source,xml]
2187--------------------------------------
2188<type name="VkResult" category="enum"/>
2189--------------------------------------
2190
2191Since this is an enumeration type, it simply links to an tag:enums tag with
2192the same name:
2193
2194[source,xml]
2195--------------------------------------
2196<enums name="VkResult" type="enum" comment="API result codes">
2197        <comment>Return codes (positive values)</comment>
2198    <enum value="0"     name="VK_SUCCESS"/>
2199    <enum value="1"     name="VK_UNSUPPORTED"/>
2200    <enum value="2"     name="VK_NOT_READY"/>
2201    ...
2202        <comment>Error codes (negative values)</comment>
2203    <enum value="-1"    name="VK_ERROR_OUT_OF_HOST_MEMORY" comment="A host memory allocation has failed"/>
2204    ...
2205--------------------------------------
2206
2207For `VkInstanceCreateInfo`, the required tag:type is:
2208
2209[source,xml]
2210--------------------------------------
2211<type category="struct" name="VkInstanceCreateInfo">
2212    <member values="VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO"><type>VkStructureType</type> <name>sType</name></member>
2213    <member>const void*                         <name>pNext</name></member>
2214    <member>const <type>VkApplicationInfo</type>* <name>pAppInfo</name></member>
2215    <member>const <type>VkAllocCallbacks</type>* <name>pAllocCb</name></member>
2216    <member><type>uint32_t</type>               <name>extensionCount</name></member>
2217    <member>const <type>char</type>*const*      <name>ppEnabledExtensionNames</name></member>
2218</type>
2219--------------------------------------
2220
2221This is a structure type, defining a C `struct` with all the members defined
2222in each tag:member tag in order.
2223In addition, it requires some other types, whose definitions are located by
2224name in exactly the same fashion.
2225
2226For the final direct dependency of the command, `VkInstance`, the required
2227tag:type is:
2228
2229[source,xml]
2230--------------------------------------
2231    <comment>Types which can be void pointers or class pointers, selected at compile time</comment>
2232<type>VK_DEFINE_BASE_HANDLE(<name>VkObject</name>)</type>
2233<type>VK_DEFINE_DISP_SUBCLASS_HANDLE(<name>VkInstance</name>, <type>VkObject</type>)</type>
2234--------------------------------------
2235
2236In this case, the type `VkInstance` is defined by a special compile time
2237macro which defines it as a derived class of `VkObject` (for `C```) or a
2238less typesafe definition (for C).
2239This macro is not part of the type dependency analysis, just the boilerplate
2240used in the header.
2241
2242If these are the only tag:feature dependencies in `vk.xml`, the resulting
2243`vulkan_core.h` header will look like this:
2244
2245[source,c]
2246--------------------------------------
2247#ifndef VULKAN_H_
2248#define VULKAN_H_ 1
2249
2250#ifdef __cplusplus
2251extern "C" {
2252#endif
2253
2254/*
2255** Copyright 2015-2021 The Khronos Group Inc.
2256    ...
2257*/
2258
2259/*
2260** This header is generated from the Khronos Vulkan XML API Registry.
2261**
2262** Generated on date 20170208
2263*/
2264
2265
2266#define VK_VERSION_1_0 1
2267#include "vk_platform.h"
2268#define VK_MAKE_VERSION(major, minor, patch) \
2269    ((major << 22) | (minor << 12) | patch)
2270
2271// Vulkan API version supported by this file
2272#define VK_API_VERSION VK_MAKE_VERSION(0, 104, 0)
2273
2274#if defined (__cplusplus) && (VK_UINTPTRLEAST64_MAX == UINTPTR_MAX)
2275    #define VK_TYPE_SAFE_COMPATIBLE_HANDLES 1
2276#endif
2277
2278#if defined(VK_TYPE_SAFE_COMPATIBLE_HANDLES) && !defined(VK_DISABLE_TYPE_SAFE_HANDLES)
2279    #define VK_DEFINE_PTR_HANDLE(_obj) struct _obj##_T { char _placeholder; }; typedef _obj##_T* _obj;
2280    #define VK_DEFINE_PTR_SUBCLASS_HANDLE(_obj, _base) struct _obj##_T : public _base##_T {}; typedef _obj##_T* _obj;
2281
2282    #define VK_DEFINE_BASE_HANDLE(_obj) VK_DEFINE_PTR_HANDLE(_obj)
2283    #define VK_DEFINE_DISP_SUBCLASS_HANDLE(_obj, _base) VK_DEFINE_PTR_SUBCLASS_HANDLE(_obj, _base)
2284    #define VK_DEFINE_NONDISP_SUBCLASS_HANDLE(_obj, _base) VK_DEFINE_PTR_SUBCLASS_HANDLE(_obj, _base)
2285#else
2286    #define VK_DEFINE_BASE_HANDLE(_obj) typedef VkUintPtrLeast64 _obj;
2287    #define VK_DEFINE_DISP_SUBCLASS_HANDLE(_obj, _base) typedef uintptr_t _obj;
2288    #define VK_DEFINE_NONDISP_SUBCLASS_HANDLE(_obj, _base) typedef VkUintPtrLeast64 _obj;
2289#endif
2290
2291typedef enum {
2292    VK_SUCCESS = 0,
2293    VK_UNSUPPORTED = 1,
2294    VK_NOT_READY = 2,
2295    ...
2296} VkResult;
2297typedef enum {
2298    VK_STRUCTURE_TYPE_APPLICATION_INFO = 0,
2299    ...
2300} VKStructureType;
2301typedef struct {
2302    VkStructureType                             sType;
2303    const void*                                 pNext;
2304    const char*                                 pAppName;
2305    uint32_t                                    appVersion;
2306    const char*                                 pEngineName;
2307    uint32_t                                    engineVersion;
2308    uint32_t                                    apiVersion;
2309} VkApplicationInfo;
2310typedef enum {
2311    VK_SYSTEM_ALLOC_TYPE_API_OBJECT = 0,
2312    ...
2313} VkSystemAllocType;
2314typedef void* (VKAPI_PTR *PFN_vkAllocFunction)(
2315    void*                           pUserData,
2316    size_t                          size,
2317    size_t                          alignment,
2318    VkSystemAllocType               allocType);
2319typedef void (VKAPI_PTR *PFN_vkFreeFunction)(
2320    void*                           pUserData,
2321    void*                           pMem);
2322typedef struct {
2323    void*                                       pUserData;
2324    PFN_vkAllocFunction                         pfnAlloc;
2325    PFN_vkFreeFunction                          pfnFree;
2326} VkAllocCallbacks;
2327typedef struct {
2328    VkStructureType                             sType;
2329    const void*                                 pNext;
2330    const VkApplicationInfo*                    pAppInfo;
2331    const VkAllocCallbacks*                     pAllocCb;
2332    uint32_t                                    extensionCount;
2333    const char*const*                           ppEnabledExtensionNames;
2334} VkInstanceCreateInfo;
2335VK_DEFINE_BASE_HANDLE(VkObject)
2336VK_DEFINE_DISP_SUBCLASS_HANDLE(VkInstance, VkObject)
2337#define VK_MAX_PHYSICAL_DEVICE_NAME       256
2338#define VK_MAX_EXTENSION_NAME             256
2339typedef VkResult (VKAPI_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, VkInstance* pInstance);
2340#ifndef VK_NO_PROTOTYPES
2341VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
2342    const VkInstanceCreateInfo*                 pCreateInfo,
2343    VkInstance*                                 pInstance);
2344#endif
2345
2346#ifdef __cplusplus
2347}
2348#endif
2349
2350#endif
2351--------------------------------------
2352
2353Note that several additional types are pulled in by the type dependency
2354analysis, but only those types, commands, and tokens required by the
2355specified features are generated.
2356
2357
2358[[compile-time-constants]]
2359== How To Add A Compile Time Constant
2360
2361Go to the desired tag:feature or tag:extension tag.
2362Add (if not present) a nested tag:require block labelled
2363
2364[source,xml]
2365--------------------------------------
2366<require comment="API constants">
2367--------------------------------------
2368
2369In this block, add an (appropriately indented) tag like
2370
2371[source,xml]
2372--------------------------------------
2373    <enum name="VK_THE_ANSWER"/>
2374--------------------------------------
2375
2376Then go to the tag:enums block labelled
2377
2378[source,xml]
2379--------------------------------------
2380<enums comment="Misc. hardcoded constants - not an enumerated type">
2381--------------------------------------
2382
2383In this block, add a tag whose attr:name attribute matches the attr:name you
2384defined above and whose attr:value attribute is the value to give the
2385constant:
2386
2387[source,xml]
2388--------------------------------------
2389    <enum value="42" type="uint32_t" name="VK_THE_ANSWER"/>
2390--------------------------------------
2391
2392The attr:type attribute must be present, and must have one of the allowed
2393values `uint32_t`, `uint64_t`, or `float`.
2394
2395
2396[[compile-time-constants-format]]
2397== Allowed Format of Compile Time Constants
2398
2399The attr:value attribute must be a legal C99 constant scalar expression when
2400evaluated at compilation time.
2401Allowed expressions are additionally restricted to the following syntax:
2402
2403  * a single C decimal integer or floating-point value
2404  * optionally prefixed with `~`
2405  * optionally suffixed with `U`, `UL`, `ULL`, or `F`
2406  * and the entire expression optionally surrounded by paired `(` and `)`.
2407
2408
2409== How To Add A Struct or Union Type
2410
2411For this example, assume we want to define a type corresponding to a C
2412`struct` defined as follows:
2413
2414[source,c]
2415--------------------------------------
2416typedef struct {
2417    VkStructureType          sType;
2418    const void*              pNext;
2419    const VkApplicationInfo* pAppInfo;
2420    const VkAllocCallbacks*  pAllocCb;
2421    uint32_t                 extensionCount;
2422    const char*const*        ppEnabledExtensionNames;
2423} VkInstanceCreateInfo;
2424--------------------------------------
2425
2426If `VkInstanceCreateInfo` is the type of a parameter of a command in the
2427API, make sure that command's definition (see below for how to add a
2428command) puts `VkInstanceCreateInfo` in nested tag:type tags where it is
2429used.
2430
2431Otherwise, if the struct type is not used directly by a command in the API,
2432nor required by a chain of type dependencies for other commands, an explicit
2433tag:type dependency should be added to the tag:feature tag.
2434Go to the tag:types tag and search for the nested block labelled
2435
2436[source,xml]
2437--------------------------------------
2438<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.">
2439    ...
2440--------------------------------------
2441
2442In this block, add a tag whose attr:name attribute matches the attr:name of
2443the struct type being defined:
2444
2445[source,xml]
2446--------------------------------------
2447<require comment="API types not used by commands">
2448    <type name="VkInstanceCreateInfo"/>
2449    ...
2450--------------------------------------
2451
2452Then go to the tag:types tag and add a new tag:type tag defining the struct
2453names and members, somewhere below the corresponding comment, like this:
2454
2455[source,xml]
2456--------------------------------------
2457<types>
2458    ...
2459        <comment>Struct types</comment>
2460    <type category="struct" name="VkInstanceCreateInfo">
2461        <member><type>VkStructureType</type>
2462                <name>sType</name></member>
2463        <member>const void*
2464                <name>pNext</name></member>
2465        <member>const <type>VkApplicationInfo</type>*
2466                <name>pAppInfo</name></member>
2467        <member>const <type>VkAllocCallbacks</type>*
2468                <name>pAllocCb</name></member>
2469        <member><type>uint32_t</type>
2470                <name>extensionCount</name></member>
2471        <member>const <type>char</type>*const*
2472                <name>ppEnabledExtensionNames</name></member>
2473    </type>
2474    ...
2475--------------------------------------
2476
2477If any of the member types are types also defined in the header, make sure
2478to enclose those type names in nested tag:type tags, as shown above.
2479Basic C types should not be tagged.
2480
2481If the type is a C `union`, rather than a `struct`, then set the value of
2482the attr:category attribute to `"union"` instead of `"struct"`.
2483
2484
2485== How To Add An Enumerated Type
2486
2487For this example, assume we want to define a type corresponding to a C
2488`enum` defined as follows:
2489
2490[source,c]
2491--------------------------------------
2492typedef enum {
2493    VK_DEVICE_CREATE_VALIDATION_BIT = 0x00000001,
2494    VK_DEVICE_CREATE_MULTI_DEVICE_IQ_MATCH_BIT = 0x00000002;
2495} VkDeviceCreateFlagBits.
2496--------------------------------------
2497
2498If `VkDeviceCreateFlagBits` is the type of a parameter to a command in the
2499API, or of a member in a structure or union, make sure that command
2500parameter or struct member's definition puts `VkDeviceCreateFlagBits` in
2501nested tag:type tags where it is used.
2502
2503Otherwise, if the enumerated type is not used directly by a command in the
2504API, nor required by a chain of type dependencies for commands and structs,
2505an explicit tag:type dependency should be added to the tag:feature tag in
2506exactly the same fashion as described above for `struct` types.
2507
2508Next, go to the line labelled
2509
2510[source,xml]
2511--------------------------------------
2512<comment>Vulkan enumerant (token) definitions</comment>
2513--------------------------------------
2514
2515At an appropriate point below this line, add an tag:enums tag whose
2516attr:name attribute matches the tag:type name `VkDeviceCreateFlagBits`, and
2517whose contents correspond to the individual fields of the enumerated type:
2518
2519[source,xml]
2520--------------------------------------
2521<enums name="VkDeviceCreateFlagBits" type="bitmask">
2522    <enum bitpos="0" name="VK_DEVICE_CREATE_VALIDATION_BIT"/>
2523    <enum bitpos="1" name="VK_DEVICE_CREATE_MULTI_DEVICE_IQ_MATCH_BIT"/>
2524</enums>
2525--------------------------------------
2526
2527Several other attributes of the tag:enums tag can be set.
2528In this case, the attr:type attribute is set to `"bitmask"`, indicating that
2529the individual enumerants represent elements of a bitmask.
2530
2531The individual tag:enum tags define the enumerants, just like the definition
2532for compile time constants described above.
2533In this case, because the enumerants are bits in a bitmask, their values are
2534specified using the attr:bitpos attribute.
2535The value of this attribute must be an integer in the range [0,30]
2536specifying a single bit number, and the resulting value is printed as a
2537hexadecimal constant corresponding to that bit.
2538
2539It is also possible to specify enumerant values using the attr:value
2540attribute, in which case the specified numeric value is passed through to
2541the C header unchanged.
2542
2543
2544[[adding-bitflags]]
2545== How To Add Bit Flags
2546
2547Bit masks are defined by two types in the xml - the type of the mask itself,
2548and the type of the valid flags.
2549
2550For this example, assume we want to define bit flags that can handle up to
255164 independent values as follows:
2552
2553[source,c]
2554--------------------------------------
2555// Flag bits for VkExampleFlagBits
2556typedef VkFlags64 VkExampleFlagBits;
2557static const VkExampleFlagBits VK_EXAMPLE_NONE = 0;
2558static const VkExampleFlagBits VK_EXAMPLE_FIRST_BIT = 0x00000001;
2559static const VkExampleFlagBits VK_EXAMPLE_SECOND_BIT = 0x00000002;
2560
2561typedef VkFlags64 VkExampleFlags;
2562--------------------------------------
2563
2564An explicit tag:type dependency should be added to the tag:feature tag in
2565exactly the same fashion as described above for `struct` types.
2566
2567Firstly, a definition is needed for the flags type used as a parameter to
2568commands or member of functions.
2569Go to the line labelled:
2570
2571[source,xml]
2572--------------------------------------
2573<comment>Bitmask types</comment>
2574--------------------------------------
2575
2576At the end of the list of `VkFlags` and `VkFlags64` types, add a definition
2577of the flags type like so:
2578
2579[source,xml]
2580--------------------------------------
2581<type bitvalues="VkExampleFlagBits" category="bitmask">typedef <type>VkFlags64</type> <name>VkExampleFlags</name>;</type>
2582--------------------------------------
2583
2584The attr:category defines this as a `"bitmask"` type.
2585The attr:bitvalues attribute identifies the `*FlagBits` entry defining the
2586flag bits associated with this type.
2587
2588Next, go to the line labelled:
2589
2590[source,xml]
2591--------------------------------------
2592<comment>Types generated from corresponding enums tags below</comment>
2593--------------------------------------
2594
2595At an appropriate point in the list of enum types after this comment, add
2596the following line:
2597
2598[source,xml]
2599--------------------------------------
2600<type name="VkExampleFlagBits" category="enum"/>
2601--------------------------------------
2602
2603This defines a type for the flag bits for generators that need it.
2604The attr:category attribute of `"enum"` identifies that this is an
2605enumerated type.
2606
2607Finally, go to the line labelled:
2608
2609[source,xml]
2610--------------------------------------
2611<comment>Vulkan enumerant (token) definitions</comment>
2612--------------------------------------
2613
2614At the end of the list of enum definitions below this line, add an tag:enums
2615tag whose attr:name attribute matches the tag:type name `VkExampleFlagBits`,
2616and whose contents correspond to the individual fields of the enumerated
2617type:
2618
2619[source,xml]
2620--------------------------------------
2621<enums name="VkExampleFlagBits" type="bitmask" bitwidth="64">
2622    <enum value="0" name="VK_EXAMPLE_NONE"/>
2623    <enum bitpos="0" name="VK_EXAMPLE_FIRST_BIT"/>
2624    <enum bitpos="1" name="VK_EXAMPLE_SECOND_BIT"/>
2625</enums>
2626--------------------------------------
2627
2628The attr:type attribute is set to `"bitmask"`, indicating that the
2629individual enumerants represent elements of a bitmask.
2630The attr:bitwidth attribute is set to `"64"` indicating that this is a
263164-bit flag type.
2632
2633The individual tag:enum tags define the enumerants, just like the definition
2634for compile time constants described above.
2635In this case, a "no flags" type is defined in `VK_EXAMPLE_NONE` with the
2636attr:value attribute defining it to have a hard value of 0.
2637The other types have their values are specified using the attr:bitpos
2638attribute, as these are actual bit flag values.
2639The value of this attribute must be an integer in the range [0,63]
2640specifying a single bit number, and the resulting value is printed as a
2641hexadecimal constant corresponding to that bit.
2642
2643
2644=== 32-bit Flags
2645
2646Bit flags can also be defined using 32-bit C enum types.
2647Doing so is broadly similar to 64-bit bit flags, but with a few key
2648differences.
2649For this example, assume we want to define the same type as above, but
2650corresponding to a C `enum` and flags type defined as follows:
2651
2652[source,c]
2653--------------------------------------
2654typedef enum VkExampleFlagBits {
2655    VK_EXAMPLE_NONE
2656    VK_DEVICE_CREATE_VALIDATION_BIT = 0x00000001,
2657    VK_DEVICE_CREATE_MULTI_DEVICE_IQ_MATCH_BIT = 0x00000002;
2658} VkExampleFlagBits;
2659
2660typedef VkFlags VkExampleFlags;
2661--------------------------------------
2662
2663To add this to the xml, entries need to be added to the XML in the same way
2664as above, but with slightly different attributes:
2665
2666For the flag type definition, the entry should use `VkFlags` instead of
2667`VkFlags64`, and require the flag bits type, instead of specifying the
2668attr:bitvalues attribute:
2669
2670[source,xml]
2671--------------------------------------
2672<type requires="VkExampleFlagBits" category="bitmask">typedef <type>VkFlags</type> <name>VkExampleFlags</name>;</type>
2673--------------------------------------
2674
2675For the definition of the enumerated flag values themselves, the bitwidth
2676needs to either be changed to `"32"`, or omitted entirely (which defaults to
2677a bitwidth of 32) as follows:
2678
2679[source,xml]
2680--------------------------------------
2681<enums name="VkExampleFlagBits" type="bitmask">
2682--------------------------------------
2683
2684Note that 32-bit bitmasks must use an integer in the range [0,30] - C enums
2685are only guaranteed to support signed 32-bit integer values, and defining an
2686unsigned value for the 31st bit could change the size of the enum type.
2687The generator scripts will warn about values exceeding this range.
2688
2689
2690== How to Add A Command
2691
2692For this example, assume we want to define the command:
2693
2694[source,c]
2695--------------------------------------
2696VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
2697    const VkInstanceCreateInfo*                 pCreateInfo,
2698    VkInstance*                                 pInstance);
2699--------------------------------------
2700
2701Commands must always be explicitly required in the tag:feature tag.
2702In that tag, you can use an existing tag:require block including API
2703features which the new command should be grouped with, or define a new
2704block.
2705For this example, add a new block, and require the command by using the
2706tag:command tag inside that block:
2707
2708[source,xml]
2709--------------------------------------
2710<feature api="vulkan" name="VK_VERSION_1_0" number="1.0" comment="Vulkan core API interface definitions">
2711    ...
2712    <require comment="Device initialization">
2713        <command name="vkCreateInstance"/>
2714    </require>
2715    ...
2716</feature>
2717--------------------------------------
2718
2719The tag:require block may include a attr:comment attribute whose value is a
2720descriptive comment of the contents required within that block.
2721The comment is not currently used in header generation, but might be in the
2722future, so use comments which are polite and meaningful to users of the
2723generated header files.
2724
2725Then go to the tag:commands tag and add a new tag:command tag defining the
2726command, preferably sorted into alphabetic order with other commands for
2727ease of reading, as follows:
2728
2729[source,xml]
2730--------------------------------------
2731<commands comment="Vulkan command definitions">
2732    ...
2733    <command>
2734        <proto><type>VkResult</type>
2735               <name>vkCreateInstance</name></proto>
2736        <param>const <type>VkInstanceCreateInfo</type>*
2737               <name>pCreateInfo</name></param>
2738        <param><type>VkInstance</type>*
2739               <name>pInstance</name></param>
2740    </command>
2741    ...
2742</commands>
2743--------------------------------------
2744
2745The tag:proto tag defines the return type and function name of the command.
2746The tag:param tags define the command's parameters in the order in which
2747they are passed, including the parameter type and name.
2748The contents are laid out in the same way as the structure tag:member tags
2749described previously.
2750
2751
2752== More Complicated API Representations
2753
2754The registry schema can represent a good deal of additional information, for
2755example by creating multiple tag:feature tags defining different API
2756versions and extensions.
2757This capability is not yet relevant to Vulkan.
2758Those capabilities will be documented as they are needed.
2759
2760
2761== More Complicated Output Formats And Other Languages
2762
2763The registry schema is oriented towards C-language APIs.
2764Types and commands are defined using syntax which is a subset of C,
2765especially for structure members and command parameters.
2766It would be possible to use a language-independent syntax for representing
2767such information, but since we are writing a C API, any such representation
2768would have to be converted into C anyway at some stage.
2769
2770The `vulkan.h` header is written using an _output generator_ object in the
2771Python scripts.
2772This output generator is specialized for C, but the design of the scripts is
2773intended to support writing output generators for other languages as well as
2774purposes such as documentation (e.g. generating asciidoc fragments
2775corresponding to types and commands for use in the API specification and
2776reference pages).
2777When targeting other languages, the amount of parsing required to convert
2778type declarations into other languages is small.
2779However, it will probably be necessary to modify some of the boilerplate C
2780text, or specialize the tags by language, to support such generators.
2781
2782
2783== Additional Semantic Tagging
2784
2785The schema is being extended to support semantic tags describing various
2786properties of API features, such as:
2787
2788  * constraints on allowed scalar values to function parameters (non-`NULL`,
2789    normalized floating-point, etc.)
2790  * length of arrays corresponding to function pointer parameters
2791  * miscellaneous properties of commands such as whether the application or
2792    system is responsible for threadsafe use; which queues they may be
2793    issued on; whether they are aliases or otherwise related to other
2794    commands; etc.
2795
2796These tags will be used by other tools for purposes such as helping create
2797validation layers, generating serialization code, and so on.
2798We would like to eventually represent everything about the API that is
2799amenable to automatic processing within the registry schema.
2800Please make suggestions on the Github issue tracker.
2801
2802
2803[[general:stability]]
2804== Stability of the XML Database and Schema
2805
2806The Vulkan XML schema is evolving in response to corresponding changes in
2807the Vulkan API and ecosystem.
2808Most such change will probably be confined to adding attributes to existing
2809tags and properly expressing the relationships to them, and making API
2810changes corresponding to accepted feature requests.
2811Changes to the schema should be described in the <<changelog,change log>> of
2812this document.
2813Changes to the `.xml` files and Python scripts are logged in Github history.
2814
2815
2816[[changelog]]
2817= Change Log
2818
2819  * 2021-11-29 - Add attr:api attribute to the tag:command tag.
2820  * 2021-10-11 - Add description of the tag:formats tag for describing
2821    Vulkan `VkFormat` image formats, and of the tag:spirvextensions and
2822    tag:spirvcapabilities tags for describing enabling mechanisms for SPIR-V
2823    extensions (internal issue 2484).
2824  * 2021-08-22 - Update introductory descriptions of toolchain and scripts.
2825  * 2021-08-15 - Add an explicit description of the tag:enum attr:extends
2826    attribute as introducing a requirement for the enumerated type being
2827    extended.
2828  * 2021-07-12 - Note that tag:extension tags describing instance extensions
2829    must not have dependencies on device extensions (internal issue 2387).
2830  * 2021-06-14 - Add an `objecttype` attribute which specifies the
2831    relationship between a Vulkan handle and another member or parameter
2832    specifying the type of object that handle refers to (public issue 1536).
2833  * 2021-06-06 - Update description of the attr:supported attribute of
2834    <<tag-extension, tag:extension tags>> to mandate that `disabled`
2835    extensions are not processed (public issue 1549).
2836  * 2021-04-21 - Add the attr:limittype attribute to <<tag-type, structure
2837    tag:member tags>>, to describe how queried limits are interpreted
2838    (internal issue 2427).
2839  * 2021-03-30 - Add a description of the <<compile-time-constants-format,
2840    allowed format of compile time constants>> (internal merge request
2841    4451).
2842  * 2021-03-22 - Update allowed values for the attr:type attribute of
2843    tag:enum tags and make it mandatory (internal issue 2564).
2844  * 2021-01-11 - Expand the scope of the attr:optional attribute tag:member
2845    and tag:param tags to specify that the member or parameter may be 0 for
2846    all scalar types, not just bitmasks and array sizes (internal issue
2847    2435).
2848  * 2020-11-23 - Add `objtypeenum` attribute to <<tag:type, tag:type>> tags
2849    to link the object name to the corresponding `VK_OBJECT_TYPE_*`
2850    enumerant, if any (internal issue 2393).
2851  * 2020-11-22 - Add requirement that `pNext` members have the
2852    `optional="true"` attribute set (internal issue 2428).
2853  * 2020-10-14 - Remove advice to set the attr:noautovalidity attribute on
2854    the `pNext` member of extending structures in the <<tag:type, tag:type
2855    tag>>, since the validity generator scripts now take care of this
2856    (internal issue 2335).
2857  * 2020-06-02 - Add description of how to switch between 64- and 32-bit
2858    flags.
2859  * 2020-05-07 - Update description of <<schema:apiname, API Names>> to
2860    current usage, including allowing specifying multiple API names for a
2861    given feature or extension.
2862  * 2020-04-29 - Expand use of attr:category `basetype` in tag:type tags to
2863    include external API types.
2864  * 2020-02-20 - Clarify that tag:enum tags inside tag:remove tags must be
2865    reference enums, not containing attributes defining values.
2866  * 2020-01-13 - Restrict attr:bitpos to [0,30] to avoid poorly defined
2867    compiler behavior.
2868  * 2019-08-25 - Add attr:sortorder attribute to tag:feature and
2869    tag:extension tags.
2870  * 2018-12-06 - Specify that command aliases are not guaranteed to resolve
2871    to the same entry point in the underlying layer stack, matching a
2872    related clarification in the Vulkan Specification.
2873  * 2018-10-01 - Add description of the default value of attr:optional
2874    member and parameter attributes, if not specified.
2875  * 2018-08-28 - Add optional attr:provisional attribute to tag:extension
2876    tags.
2877  * 2018-07-07 - Add optional attr:promotedto, attr:deprecatedby, and
2878    attr:obsoletedby attributes to tag:extension tags.
2879  * 2018-06-25 - Remove attr:vendorids tags for Khronos vendor IDs.
2880  * 2018-05-08 - Add tag:driverids and tag:driverid tags for describing
2881    Vulkan driver implementation identification information.
2882  * 2018-04-15 - Add attr:requiresCore.
2883  * 2018-03-07 - Updated for Vulkan 1.1 release.
2884  * 2018-02-21 - Add descriptions of the attr:extnumber and attr:alias
2885    attributes used for defining tag:enum attributes, the attr:alias
2886    attribute used for defining tag:type aliases, the attr:name and
2887    attr:alias attributes used for defining tag:command aliases, the
2888    attr:platform attribute of tag:extension tags, and the attr:feature
2889    attribute of tag:require tags; and update the document to the header
2890    naming and grouping scheme used starting in Vulkan 1.1.
2891  * 2018-01-07 - Add tag:platforms and tag:platform tags for describing
2892    Vulkan platform names and preprocessor symbols.
2893  * 2017-09-10 - Define syntax of member and parameter attr:altlen
2894    attributes, for use by code generators.
2895  * 2017-09-01 - Define syntax of member and parameter attr:len attributes
2896    consistently and correctly for current uses of latexmath:
2897  * 2017-08-24 - Note that the tag:extension attribute attr:type must be
2898    specified if the extension is not disabled.
2899  * 2017-07-27 - Finish removing validextensionstructs attribute and
2900    replacing it with structextends.
2901  * 2017-07-14 - Add comment attributes or tags as valid content in several
2902    places, replacing XML comments which could not be preserved by XML
2903    transformation tools.
2904  * 2017-02-20 - Change to asciidoctor markup and move into the
2905    specification source directory for ease of building.
2906  * 2016-09-27 - Remove tag:validity and tag:usage tags, since these
2907    explicit usage statements have been moved to the specification source.
2908  * 2016-08-26 - Update for the single-branch model.
2909  * 2016-07-28 - Add attr:type and attr:requires attributes to tag:extension
2910    tags.
2911  * 2016-02-22 - Change math markup in attr:len attributes to use asciidoc
2912    `latexmath:[$` and `$]` delimiters.
2913  * 2016-02-19 - Add attr:successcodes and attr:errorcodes attributes of
2914    tag:command tags.
2915    Add a subsection to the introduction describing the schema choices and
2916    how to file issues against the registry.
2917  * 2016-02-07 - Add attr:vendorids tags for Khronos vendor IDs.
2918  * 2015-12-10 - Add attr:author and attr:contact attributes for
2919    tag:extension tags.
2920  * 2015-12-07 - Move `vulkan/vulkan.h` to a subdirectory.
2921  * 2015-12-01 - Add tag:tags tags for author tags.
2922  * 2015-11-18 - Bring documentation and schema up to date for extension
2923    enumerants.
2924  * 2015-11-02 - Bring documentation and schema up to date with several
2925    recent merges, including tag:validity tags.
2926    Still out of date WRT extension enumerants, but that will change soon.
2927  * 2015-09-08 - Rename `threadsafe` attribute to attr:externsync, and
2928    `implicitunsafeparams` tag to attr:implicitexternsync.
2929  * 2015-09-07 - Update tag:command tag description to remove the
2930    attr:threadsafe attribute and replace it with a combination of
2931    attr:threadunsafe attributes on individual parameters, and
2932    tag:implicitunsafeparams tags describing additional unsafe objects for
2933    the command.
2934  * 2015-08-04 - Add `basetype` and `funcpointer` attr:category values for
2935    type tags, and explain the intended use and order in which types in each
2936    category are emitted.
2937  * 2015-07-02 - Update description of Makefile targets.
2938    Add descriptions of attr:threadsafe, attr:queues, and attr:renderpass
2939    attributes of <<tag-command,tag:command>> tags, and of attr:modified
2940    attributes of <<tag-command:param,tag:param>> tags.
2941  * 2015-06-17 - add descriptions of allowed attr:category attribute values
2942    of tag:type tags, used to group and sort related categories of
2943    declarations together in the generated header.
2944  * 2015-06-04 - Add <<examples,examples of making changes and additions>>
2945    to the registry.
2946  * 2015-06-03 - Move location to new `vulkan` Git repository.
2947    Add definition of tag:type tags for C struct/unions.
2948    Start adding <<examples,examples of making changes>>.
2949  * 2015-06-02 - Branch from OpenGL specfile documentation and bring up to
2950    date with current Vulkan schema.
2951  * 2015-07-10 - Remove contractions to match the style guide.
2952  * 2015-07-19 - Move this document from LaTeX to asciidoc source format and
2953    make minor changes to markup.
2954