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