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