• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2013-2021 The Khronos Group Inc.
2#
3# SPDX-License-Identifier: Apache-2.0
4
5# Relax NG schema for Khronos Vulkan API Registry XML
6#
7# See https://www.khronos.org/vulkan/
8#
9# This definition is subject to change (mostly in the form of additions)
10
11namespace xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
12
13# Toplevel is a <registry> tag.
14# May be led by an optional <comment> tag containing e.g. copyrights.
15start = element registry {
16    (
17        element comment { text } ? |
18        Platforms         * |
19        Tags              * |
20        Types             * |
21        Enums             * |
22        Commands          * |
23        Feature           * |
24        Extensions        * |
25        Formats           * |
26        SpirvExtensions   * |
27        SpirvCapabilities *
28    ) *
29}
30
31# <platforms> defines a group of platform names
32Platforms = element platforms {
33    Comment ? ,
34    Platform *
35}
36
37# <platform> defines a single platform name.
38#   name - string name of the platform, used as part of extension names
39#   protect - preprocessor symbol to include platform headers from <vulkan.h>
40#   comment - platform description
41Platform = element platform {
42    attribute name { text } ,
43    attribute protect { text } ,
44    Comment
45}
46
47# <tags> defines a group of author tags
48Tags = element tags {
49    Comment ? ,
50    Tag *
51}
52
53# <tag> defines a single author tag.
54#   name - name of the tag
55#   author - name of the author (usually a company or project name)
56#   contact - contact responsible for the tag (name and contact information)
57Tag = element tag {
58    attribute name { text } ,
59    attribute author { text } ,
60    attribute contact { text }
61}
62
63# <types> defines a group of types
64Types = element types {
65    Comment ? ,
66    (
67        Type |
68        element comment { text }
69    ) *
70}
71
72# <type> defines a single type. It is usually a C typedef but
73# may contain arbitrary C code.
74#   name - name of this type, if not present in the <name> tag
75#   api - matches a <feature> api attribute, if present
76#   alias - name of a type this type aliases
77#   requires - name of another type definition required by this one
78#   bitvalues - for a *Flags type, name of an enum definition that
79#       defines the valid values for parameters of that type
80#   name - name of the type being defined
81#   category - if present, 'enum' indicates a matching <enums>
82#       block to generate an enumerated type for, and 'struct'
83#       causes special interpretation of the contents of the type
84#       tag including ... TBD ...
85#       Other allowed values are 'include', 'define', 'handle' and 'bitmask',
86#       which do not change syntactic interpretation but allow organization
87#       in the generated header.
88#   parent - only applicable if category is 'handle'. Notes another type with
89#       the 'handle' category that acts as a parent object for this type.
90#   returnedonly - only applicable if category is 'struct'. Notes that this
91#       struct is going to be filled in by the API, rather than an application
92#       filling it out and passing it to the API.
93#   structextends - only applicable if category is 'struct'. Lists parent
94#       structures which this structure may extend via the pNext chain
95#       of the parent.
96#       When present it suppresses generation of automatic validity for the
97#       pNext member of that structure, and instead the structure is added
98#       to pNext chain validity for the parent structures it extends.
99#   allowduplicate - only applicable if category is 'struct'. pNext can include
100#       multiple structures of this type.
101#   objtypeenum - name of VK_OBJECT_TYPE_* API enumerant which corresponds
102#       to this type. Currently only specified for category="handle" types.
103#   comment - descriptive text with no semantic meaning
104# For types without a category, contents include
105#   <apientry /> - substitutes for an APIENTRY-style macro on output
106#   <name> - contains name of the type being defined
107#   <type> - contains name of types used to define this type. There
108#       may be multiple imbedded <type> tags
109# For types with category 'enum', contents should be empty
110# For types with category 'struct', contents should be one or more
111#   <member> - like <param> for a struct or union member
112#       len - if the member is an array, len may be one or more of the following
113#           things, separated by commas (one for each array indirection):
114#           another member of that struct, 'null-terminated' for a string,
115#           '1' to indicate it is just a pointer (used for nested pointers),
116#           or a latex equation (prefixed with 'latexmath:')
117#       altlen - if len has latexmath equations, this contains equivalent C99
118#                expressions separated by commas.
119#       externsync - denotes that the member should be externally synchronized
120#           when accessed by Vulkan
121#       optional - whether this value can be omitted by providing NULL (for
122#           pointers), VK_NULL_HANDLE (for handles) or 0 (for bitmasks/values)
123#       selector - for a union member, identifies a separate enum member that
124#           selects which of the union's members are valid
125#       selection - for a member of a union, identifies an enum value indicating the member is valid
126#       noautovalidity - tag stating that no automatic validity language should be generated
127#       values - comma-separated list of legal values, usually used only for sType enums
128#       limittype - only applicable for members of VkPhysicalDeviceProperties and
129#           VkPhysicalDeviceProperties2, their substrucutres, and extensions.
130#           Specifies the type of a device limit.
131#           Valid values: 'min', 'max', 'bitmask', 'range', 'struct', 'noauto'
132#       objecttype - only applicable for members representing a handle as
133#           a uint64_t value. Specifies the name of another member which is
134#           a VkObjectType or VkDebugReportObjectTypeEXT value specifying
135#           the type of object the handle references.
136#   <comment> - containing arbitrary text (unused)
137#
138# *** There is a problem here: I am not sure how to represent the <type>
139# syntax where it may contain arbitrarily interleaved text, <type>, and
140# <enum> child tags. This allows only the syntax
141#   text <type>name</type> text <enum>name</enum> text
142# where <type> and <enum> are both optional and occur in the specified
143# order, which might eventually be a problem.
144Type = element type {
145    attribute api { text } ? ,
146    attribute alias { text } ? ,
147    attribute requires { text } ? ,
148    attribute bitvalues { text } ? ,
149    attribute name { TypeName } ? ,
150    attribute category { text } ? ,
151    attribute parent { TypeName } ? ,
152    attribute returnedonly { text } ? ,
153    attribute structextends { text } ? ,
154    attribute allowduplicate { text } ? ,
155    attribute objtypeenum { text } ? ,
156    Comment ? ,
157    (
158        (
159            ( text ,
160              element type { text } *
161            ) * ,
162            element apientry { text } ? ,
163            ( text ,
164              element type { text } *
165            ) * ,
166            element name { TypeName } ? ,
167            ( text ,
168              element type { text } *
169            ) *
170        ) |
171        (
172            element member {
173                attribute len { text } ? ,
174                attribute altlen { text } ? ,
175                attribute externsync { text } ? ,
176                attribute optional { text } ? ,
177                attribute selector { text } ? ,
178                attribute selection { EnumName } ? ,
179                attribute noautovalidity { text } ? ,
180                attribute values { text } ? ,
181                attribute limittype { text } ? ,
182                attribute objecttype { text } ? ,
183                mixed {
184                    element type { TypeName } ? ,
185                    element name { text } ? ,
186                    element enum { EnumName } ? ,
187                    element comment { text } ?
188                }
189            } |
190            element comment { text }
191        ) *
192    )
193}
194
195# <enums> defines a group of enumerants
196#   name - identifies a type name associated with this group. Should
197#       match a <type> name to trigger generation of the type.
198#   start, end - beginning and end of a numeric range
199#   vendor - owner of the numeric range
200#   type - 'enum' or 'bitmask', if present
201#   bitwidth - bit width of the enum value type.
202#   comment - descriptive text with no semantic meaning
203Enums = element enums {
204    attribute name { text } ? ,
205    attribute type { text } ? ,
206    attribute start { Integer } ? ,
207    attribute end { Integer } ? ,
208    attribute bitwidth { Integer } ? ,
209    Vendor ? ,
210    Comment ? ,
211    (
212        Enum |
213        Unused |
214        element comment { text}
215    ) *
216}
217
218# <enum> defines or references a single enumerant. There are two places it
219# can be used: in an <enums> block, providing a global definition which
220# may later be required by a feature or extension; or in a feature or
221# extension, defining an enumerant specific to that feature. The second
222# form has more possible attributes. Some combinations of attributes are
223# nonsensical in on or the other place, but these are not detected by the
224# validator.
225#
226# Ways to specify the enumerant value:
227#   value - integer (including hex) value of the enumerant
228#   bitpos - integer bit position of the enumerant in a bitmask
229#   [extnumber], offset, [dir] - integer extension number specifying a
230#       base block value (inherited from surrounding <extension> if
231#       not specified); integer offset in that block; and direction
232#       of offset ('-' for negative, positive if not specified).
233#   alias - name of another enum this is an alias of
234#
235# value and bitpos allow, and extnumber/offset/dir require:
236#   extends - type name of the enumerant being extended
237#
238# Other attributes:
239#   api - matches a <feature> api attribute, if present
240#   type - 'uint32_t', 'uint64_t', or 'float', if present. There are
241#       certain conditions under which the tag must be present, or absent,
242#       but they are context-dependent and difficult to express in the
243#       RNC syntax.
244#   name - enumerant name
245#   alias - another enumerant this is semantically identical to
246#   protect - additional #ifdef symbol to place around the enum
247#   comment - descriptive text with no semantic meaning
248Enum = element enum {
249    (
250      (
251        (
252          attribute value { Integer } &
253          attribute extends { TypeName } ?
254        ) |
255        (
256          attribute bitpos { Integer } &
257          attribute extends { TypeName } ?
258        ) |
259        (
260          attribute extnumber { Integer } ? &
261          attribute offset { Integer } &
262          attribute dir { text } ? &
263          attribute extends { TypeName }
264        ) |
265        (
266          attribute extends { TypeName } ? &
267          attribute alias { TypeName }
268        )
269      ) ? &
270      attribute protect { text } ? &
271      attribute api { text } ? &
272      attribute type { TypeSuffix } ? &
273      attribute name { text } &
274      Comment ?
275    )
276}
277
278# <unused> defines a range of enumerants not currently being used
279#   start, end - beginning and end of an unused numeric range
280#   vendor - unused
281#   comment - descriptive text with no semantic meaning
282Unused = element unused {
283    attribute start { Integer } ,
284    attribute end { Integer } ? ,
285    Vendor ? ,
286    Comment ?
287}
288
289# <commands> defines a group of commands
290Commands = element commands {
291    Comment ? ,
292    Command *
293}
294
295# <command> defines a single command
296#
297# There are two forms of the tag.
298#
299# Either form may have an 'api' attribute
300#   api - matches a <feature> api attribute, if present
301#
302# The first form only has 'name' and 'alias' attributes, and no contents.
303# It defines a command alias.
304#
305# The second form fully defines a command, and has the following structure:
306# The possible attributes are not described in this comment block yet, but
307# are in readme.pdf. The "prefix" and "suffix" attributes are currently
308# present only in the OpenCL XML registry, where they are currently unused.
309#
310#   <proto> is the C function prototype, including the return type
311#   <param> are function parameters, in order
312#     len - if the member is an array, len may be one or more of the following
313#           things, separated by commas (one for each array indirection):
314#           another member of that struct, 'null-terminated' for a string,
315#           '1' to indicate it is just a pointer (used for nested pointers),
316#           or a latex equation (prefixed with 'latexmath:')
317#     altlen - if len has latexmath equations, this contains equivalent C99
318#              expressions separated by commas.
319#     externsync - denotes that the member should be externally synchronized
320#         when accessed by Vulkan
321#     optional - whether this value can be omitted by providing NULL (for
322#         pointers), VK_NULL_HANDLE (for handles) or 0 (for bitmasks/values)
323#     selector - for a union parameter, identifies a separate enum parameter that
324#         selects which of the union's members are valid
325#     noautovalidity - tag stating that no automatic validity language should be
326#         generated
327#     objecttype - only applicable for parameters representing a handle as
328#         a uint64_t value. Specifies the name of another parameter which is
329#         a VkObjectType or VkDebugReportObjectTypeEXT value specifying
330#         the type of object the handle references.
331#     <type> is a <type> name, if present
332#     <name> is the function / parameter name, if present (normally should
333#         be, except for void parameters).
334# The textual contents of <proto> and <param> should be legal C
335# for those parts of a function declaration.
336#   <alias> - denotes function aliasing, if present
337#     name - name of aliased function
338#   <description> - unused text
339#   <implicitexternsyncparams> are spec-language descriptions of
340#       objects that are not parameters of the command, but
341#       are related to them and also require external synchronization.
342Command = element command {
343    (   attribute name { text } ,
344        attribute alias { text } ,
345        attribute api { text } ?
346        ) |
347    (
348        attribute queues { text } ? ,
349        attribute successcodes { text } ? ,
350        attribute errorcodes { text } ? ,
351        attribute renderpass { text } ? ,
352        attribute cmdbufferlevel { text } ? ,
353        attribute prefix { text } ? ,
354        attribute suffix { text } ? ,
355        attribute api { text } ? ,
356        Comment ? ,
357        element proto {
358            mixed {
359                element type { TypeName } ? ,
360                element name { text }
361            }
362        } ,
363        element param {
364            attribute len { text } ? ,
365            attribute altlen { text } ? ,
366            attribute externsync { text } ? ,
367            attribute optional { text } ? ,
368            attribute selector { text } ? ,
369            attribute noautovalidity { text } ? ,
370            attribute objecttype { text } ? ,
371            mixed {
372                element type { TypeName } ? ,
373                element name { text } ?
374            }
375        } * ,
376        (
377            element alias {
378                Name
379            } ? &
380            element description {
381                text
382            } ? &
383            element implicitexternsyncparams {
384                element param { text } *
385            } ?
386        )
387    )
388}
389
390# Each <feature> defines the interface of an API version (e.g. OpenGL 1.2)
391#   api - API tag (e.g. 'gl', 'gles2', etc. - used internally, not
392#     necessarily an actual API name
393#   name - version name (C preprocessor name, e.g. GL_VERSION_4_2)
394#   number - version number, e.g. 4.2
395#   protect - additional #ifdef symbol to place around the feature
396#   sortorder - order relative to other features, default 0
397#   <require> / <remove> contains features to require or remove in
398#                        this version
399#     profile - only require/remove when generated profile matches
400#     comment - descriptive text with no semantic meaning
401Feature = element feature {
402    attribute api { text } ,
403    Name ,
404    attribute number { xsd:float } ,
405    attribute protect { text } ? ,
406    attribute sortorder { xsd:integer } ?,
407    Comment ? ,
408    (
409        element require {
410            ProfileName ? ,
411            ExtensionName ? ,
412            Comment ? ,
413            (
414                InterfaceElement |
415                element comment { text }
416            ) *
417        } |
418        element remove {
419            ProfileName ? ,
420            Comment ? ,
421            (
422                InterfaceElement |
423                element comment { text }
424            ) *
425        }
426    ) *
427}
428
429Extensions = element extensions {
430    Comment ? ,
431    Extension *
432}
433
434# Each <extension> defines the interface of an API <extension>.
435# Like a <feature> tag, but with slightly different attributes:
436#   api - regexp pattern matching one or more API tags, indicating
437#     which APIs the extension is known to work with. The only
438#     syntax supported is <name>{|<name>}* and each name must
439#     exactly match an API being generated (implicit ^$ surrounding).
440#   name - extension name string
441#   number - extension number (positive integer, should be unique)
442#   sortorder - order relative to other extensions, default 0
443#   protect - C preprocessor symbol to conditionally define the interface
444#   platform - should be one of the platform names defined in the
445#     <platform> tag. Currently unused.
446#   author - name of the author (usually a company or project name)
447#   contact - contact responsible for the tag (name and contact information)
448#   type - 'device' or 'instance', if present
449#   requires - commas-separated list of extension names required by this
450#       extension
451#   requiresCore - core version of Vulkan required by the extension, e.g.
452#       "1.1". Defaults to "1.0".
453#   supported - profile name(s) supporting this extension, e.g. 'vulkan'
454#       or 'disabled' to never generate output.
455#   promotedto - Vulkan version or a name of an extension that this
456#       extension was promoted to; e.g. 'VK_VERSION_1_1', or
457#       'VK_KHR_draw_indirect_county'
458#   deprecatedby - Vulkan version or a name of an extension that deprecates
459#       this extension. It may be empty string.
460#       e.g. 'VK_VERSION_1_1', or 'VK_EXT_debug_utils', or ''
461#   obsoletedby - Vulkan version or a name of an extension that obsoletes
462#       this extension. It may be empty string.
463#       e.g. 'VK_VERSION_1_1', or 'VK_EXT_debug_utils', or ''
464#   provisional - 'true' if this extension is released provisionally
465#   specialuse - contains one or more tokens separated by commas, indicating
466#       a special purpose of the extension. Tokens may include 'cadsupport',
467#       'd3demulation', 'devtools', 'debugging', and 'glemulation'. Others
468#       may be added in the future.
469# In addition, <require> / <remove> tags also support an api attribute:
470#     api - only require/remove these features for the matching API.
471#       Not a regular expression.
472Extension = element extension {
473    Name ,
474    attribute number { Integer } ? ,
475    attribute sortorder { xsd:integer } ?,
476    attribute protect { text } ? ,
477    attribute platform { text } ? ,
478    attribute author { text } ? ,
479    attribute contact { text } ? ,
480    attribute type { text } ? ,
481    attribute requires { text } ? ,
482    attribute requiresCore { text } ? ,
483    attribute supported { StringGroup } ? ,
484    attribute promotedto { text } ? ,
485    attribute deprecatedby { text } ? ,
486    attribute obsoletedby { text } ? ,
487    attribute provisional { text } ? ,
488    attribute specialuse { text } ? ,
489    Comment ? ,
490    (
491        element require {
492            attribute api { text } ? ,
493            ProfileName ? ,
494            ExtensionName ? ,
495            FeatureName ? ,
496            Comment ? ,
497            (
498                InterfaceElement |
499                element comment { text }
500            ) *
501        } |
502        element remove {
503            attribute api { text } ? ,
504            ProfileName ? ,
505            Comment ? ,
506            (
507                InterfaceElement |
508                element comment { text }
509            ) *
510        }
511    ) *
512}
513
514# Each <format> define information about a VkFormat in a machine readable format
515Formats = element formats {
516    Format *
517}
518
519#    name - Format name, matching a VkFormat enum name
520#    class - Used for 'Compatible Formats' table
521#    blockSize - Used for 'Compatible Formats' table
522#    texelsPerBlock - Used for 'Compatible Formats' table
523#    blockExtent - 3D extent, no attribute is same as blockExtent=1,1,1
524#    packed - number of bits data type
525#    compressed - compression format class
526#    planes - number of planes, no attribute is same as planes=1
527#    chroma - can be one of [420, 422, 444] and used to mark if YCbCr Sampler are required by default
528Format = element format {
529    Name ,
530    attribute class { text } ,
531    attribute blockSize { text } ,
532    attribute texelsPerBlock { text } ,
533    attribute blockExtent { text } ? ,
534    attribute packed { text } ? ,
535    attribute compressed { text } ? ,
536    attribute chroma { text } ? ,
537    Component + ,
538    Plane * ,
539    SpirvImageFormat *
540}
541
542#   bits - size of component or "compressed" if part of block-compression format
543#   numericFormat - as per Interpretation of Numeric Format table
544#       some formats (depth/stencil) will have different numeric per component
545#   planeIndex - For multi-planar formats to map to the plane element
546Component = element component {
547    Name ,
548    attribute bits { text } ,
549    attribute numericFormat { text },
550    attribute planeIndex { text } ?
551}
552
553# For multi-planar formats
554Plane = element plane {
555    attribute index { text } ,
556    attribute widthDivisor { text } ,
557    attribute heightDivisor { text } ,
558    attribute compatible { text }
559}
560
561# labels a SPIR-V Image Format
562SpirvImageFormat = element spirvimageformat {
563    Name
564}
565
566# Each <spirvextension> define a SPIR-V extension that can be used in the API.
567# Each <spirvcapability> define a SPIR-V capability that can be used in the API.
568# Contains information to both generate table in spec as well as validating
569# what needs to be enabled or supported to be used in Vulkan
570SpirvExtensions = element spirvextensions {
571    Comment ? ,
572    SpirvExtension *
573}
574
575SpirvExtension = element spirvextension {
576    Name ,
577    Enable +
578}
579
580SpirvCapabilities = element spirvcapabilities {
581    Comment ? ,
582    SpirvCapability *
583}
584
585SpirvCapability = element spirvcapability {
586    Name ,
587    Enable +
588}
589
590# <enable> defines a way to enable the parent element in the API.
591# If anyone of the <enable> elements are valid then the parent element
592# can be used.
593#
594# There are four forms of the tag.
595#
596# The first only has the minimal version of Vulkan of the application
597#
598# The second only has a single Vulkan extension that must be enabled
599#
600# The third has a single Vulkan feature with the struct where it is from
601#
602# The fourth has a property struct, the member field in it, and the value
603# that must be present
604#
605# To make scripting easier, each <enable> has a require attribute to map
606# to the asciidoctor conditional logic in the spec. For version and
607# extension attribute variations, there is no need for the require attribute
608# since it is a redundant 1:1 mapping.
609#
610# The 'alias' attribute is used in cases where the anchor link cannot be
611# propertly resolved and needs a manual name to link to
612Enable = element enable {
613    (
614        attribute version { text } ) |
615    (
616        attribute extension { text } ) |
617    (
618        attribute struct { text },
619        attribute feature { text },
620        attribute requires { text },
621        attribute alias { text } ? ) |
622    (
623        attribute property { text },
624        attribute member { text },
625        attribute value { text },
626        attribute requires { text } ? )
627}
628
629# Contents of a <require> / <remove> tag, defining a group
630# of features to require or remove.
631#   <type> / <enum> / <command> all have attributes
632#     name - feature name which must match
633InterfaceElement =
634    element type {
635        Name ,
636        Comment ?
637    } |
638    Enum |
639    element command {
640        Name ,
641        Comment ?
642    }
643
644# Integers are allowed to be either decimal or C-hex (0x[0-9A-F]+), but
645# XML Schema types do not seem to support hex notation, so we use this
646# as a placeholder.
647Integer = text
648
649# EnumName is an compile-time constant name
650EnumName = text
651
652# TypeName is an argument/return value C type name
653TypeName = text
654
655# TypeSuffix is a C numeric type suffix, e.g. 'u' or 'ull'
656TypeSuffix = text
657
658# StringGroup is a regular expression with an implicit
659#   '^(' and ')$' bracketing it.
660StringGroup = text
661
662# Repeatedly used attributes
663ProfileName = attribute profile { text }
664ExtensionName = attribute extension { text }
665FeatureName = attribute feature { text }
666Vendor = attribute vendor { text }
667Comment = attribute comment { text }
668Name = attribute name { text }
669