1\documentclass{article} 2 3% Various packages of possible use. {index} creates problems for some reason. 4% \usepackage{index} 5\def\specpdftitle{The Khronos XML API Registry} 6\usepackage[pdftex,bookmarksnumbered=true,linktocpage,plainpages=false,pdftitle={\specpdftitle},colorlinks=true]{hyperref} 7\usepackage{amsmath,enumerate,epsfig,framed,mdframed,multicol,longtable,times,url} 8\usepackage[normalem]{ulem} 9% underscore allows use of _ instead of \_ in text. [strings] allows _ in file names 10\usepackage[strings]{underscore} 11\usepackage[breakwords,fit]{truncate} 12 13\makeatletter 14\makeatother 15\makeindex 16 17% Some commonly used abbreviations 18 19\def\code#1{{\tt #1}} 20\def\tag#1{{\tt <#1>\index{<#1>}}} 21\def\attr#1{{\tt #1\index{#1}}} 22 23\begin{document} 24 25\title{The Khronos XML API Registry} 26\author{Jon Leech} 27\date{Last updated 2017-01-20} 28\maketitle 29 30\begin{abstract} 31 32This document describes the Khronos XML API Registry schema, and provides 33some additional information about using the registry and scripts to generate 34C header files. The underlying XML files and scripts, as well as headers 35generated from the current authoritative copy of the XML files, can be 36obtained from the OpenGL-Registry github repository at 37 38\begin{center} 39{\bf \href{https://github.com/KhronosGroup/OpenGL-Registry} 40 {https://github.com/KhronosGroup/OpenGL-Registry}} 41\end{center} 42 43\end{abstract} 44 45\tableofcontents 46 47\section{Introduction} 48 49The registry uses an XML representation of the API and a set of Python 3 50scripts to manipulate the XML, based on the lxml Python bindings. It comes 51with an XML schema and validator. Outside users are welcome to submit pull 52requests on github, although the XML schema itself is mature and unlikely to 53change at this point. 54 55Some groups outside Khronos have their own XML based API descriptions, 56often used for additional purposes such as library code generators or 57extension loaders, and it may be desirable to construct XSLT or other 58translators between the schema. 59 60 61\section{Getting Started} 62 63Once the repository has been downloaded, if you're running 64in a Linux command-line environment and have Python 3, the lxml Python 65bindings, and libxml installed, you should just be able to invoke 66\code{make} and generate C/C++ header files for all the following 67targets: 68 69\begin{itemize} 70\item \code{GL/glext.h} - OpenGL 1.2 (and later) compatibility profile 71 API + extensions 72\item \code{GL/glcorearb.h} - OpenGL core profile API + extensions 73\item \code{GLES/gl.h} - OpenGL compatibility profile API 74\item \code{GLES/glext.h} - OpenGL ES 1.x extensions 75\item \code{GLES2/gl2.h} - OpenGL ES 2.x API 76\item \code{GLES2/gl2ext.h} - OpenGL ES 2.x extensions 77\item \code{GLES3/gl3.h} - OpenGL ES 3.x API 78\item \code{GL/glx.h} - GLX API 79\item \code{GL/glxext.h} - GLX 1.3 (and later) API + extensions 80\item \code{GL/wgl.h} - WGL API 81\item \code{GL/wglext.h} - WGL extensions 82\item \code{EGL/egl.h} - EGL (still being worked on) 83\end{itemize} 84 85Starting with the Makefile rules and inspecting the files \code{gl.xml}, 86\code{genheaders.py}, and \code{reg.py} will be necessary if you want to 87repurpose the registry for reasons other than header file generation, or 88to generate headers for languages other than C. 89 90If you're running in a Microsoft Windows, MaxOS X, or other non-Linux 91environment, there are equivalent versions of Python and GNU Make, although 92we haven't tested this ourselves. Feedback would be helpful. If you're using 93Windows 10, you should probably try to build in the Ubuntu Linux subsystem 94rather than older Unix emulation environments such as Cygwin. 95 96 97\subsection{Header Generation Script - \code{genheaders.py}} 98 99When generating header files using the \code{genheaders.py} script, an 100API name and profile name are required, as shown in the Makefile 101examples. Additionally, specific versions and extensions can be required 102or excluded. Based on this information, the generator script extracts 103the relevant interfaces and creates a C-language header file for them. 104\code{genheaders.py} contains predefined generator options for OpenGL compatibility 105and core profiles, OpenGL ES 1 / 2 / 3, GLX, and WGL headers. 106 107The generator script is intended to be generalizable to other languages 108by writing new generator classes. Such generators would have to rewrite 109the C types and definitions in the XML to something appropriate to their 110language. 111 112\subsection{Registry Processing Script - \code{reg.py}} 113 114Actual XML registry processing is done in \code{reg.py}, which contains 115several objects and methods for loading registries and extracting 116interfaces and extensions for use in header generation. There is some 117internal documentation in the form of comments although nothing more 118extensive exists yet, and it's possible the Python scripts will evolve 119significantly based on public feedback. 120 121 122\section{XML Registry Schema} 123\label{schema} 124 125The format of an XML registry is a top level \tag{registry} tag 126containing \tag{types}, \tag{enums}, \tag{commands}, \tag{feature}, and 127\tag{extension} tags describing the different elements of an API, as 128explained below. This description corresponds to a formal Relax NG 129schema file, \code{registry.rnc}, against which the XML registry files 130can be validated. 131 132At present there are separate registries for: 133 134\begin{itemize} 135\item OpenGL and OpenGL ES - \code{gl.xml} 136\item GLX - \code{glx.xml} 137\item WGL - \code{wgl.xml} 138\item EGL - \code{egl.xml} (still in development) 139\end{itemize} 140 141\subsection{Profiles} 142\label{schema:profile} 143 144Types and enumerants can have different definitions depending on the API 145profile requested, which allows us to accomodate minor incompatibilities 146in the OpenGL and OpenGL ES APIs, for example. Features and extensions 147can include some elements conditionally depending on the API profile 148requested. 149 150\subsection{API Names} 151\label{schema:apiname} 152 153Several tags use a \attr{api} attribute. This is an arbitrary string, 154specified at header generation time, for labelling properties of a 155specific API. The string can be, but is not necessarily, an actual API 156name. As used in \code{genheaders.py} and \code{gl.xml}, the API names 157are \code{gl}, \code{gles1}, and \code{gles2}, corresponding to OpenGL, 158OpenGL ES 1, and OpenGL ES 2/3, respectively. 159 160 161\section{Registry Root (\tag{registry} tag)} 162\label{schema:root} 163 164A \tag{registry} contains the entire definition of one or more related 165APIs. 166 167\subsection{Attributes of \tag{registry} tags} 168 169None. 170 171\subsection{Contents of \tag{registry} tags} 172 173Zero or more of each of the following tags, normally in this order 174(although order shouldn't be important): 175 176\begin{itemize} 177\item \tag{comment} - Contains arbitrary text, such as a copyright 178 statement. Unused. 179\item \tag{types} (see section~\ref{tag:types}) - defines API types. 180 Usually only one tag is used. 181\item \tag{groups} (see section~\ref{tag:groups}) - defines named groups 182 of tokens for possible parameter validation in API bindings for 183 languages other than C. Usually only one tag is used. 184\item \tag{enums} (see section~\ref{tag:enums}) - defines API enumerants 185 (tokens). Usually multiple tags are used. 186\item \tag{commands} (see section~\ref{tag:commands}) - defines API 187 commands (functions). Usually only one tag is used. 188\item \tag{feature} (see section~\ref{tag:feature}) - defines API 189 feature interfaces (API versions, more or less). One tag per 190 feature set. 191\item \tag{extensions} (see section~\ref{tag:extensions}) - defines API 192 extension interfaces. Usually only one tag is used, wrapping many 193 extensions. 194\end{itemize} 195 196 197\section{API types (\tag{types} tag)} 198\label{tag:types} 199 200The \tag{types} tag contains individual \tag{type} tags describing each 201of the derived types used in the API. 202 203Each \tag{type} tag contains legal C code, with attributes or embedded 204tags denoting the type name. 205 206\subsection{Attributes of \tag{type} tags} 207 208\begin{itemize} 209\item \attr{requires} - another type name this type requires to complete 210 its definition. 211\item \attr{name} - name of this type (if not defined in the tag body). 212\item \attr{api} - an API name (see \tag{feature} below) which 213 specializes this definition of the named type, so that the same 214 API types may have different definitions for e.g. GL ES and GL. 215\item \attr{comment} - arbitrary string (unused). 216\end{itemize} 217 218\subsection{Contents of \tag{type} tags} 219 220\tag{type} contains text which is legal C code for a type declaration. 221It may also contain embedded tags: 222 223\begin{itemize} 224\item \tag{apientry/} - insert a platform calling convention macro here 225 during header generation, used mostly for function pointer types. 226\item \tag{name} - contains the name of this type (if not defined in the 227 tag attributes). 228\end{itemize} 229 230\subsection{Example of a \tag{types} tag} 231 232\begin{verbatim} 233<types> 234 <type name="stddef"><![CDATA[#include <stddef.h>]]></type> 235 <type requires="stddef">typedef ptrdiff_t <name>GLintptr</name>;</type> 236</types> 237\end{verbatim} 238 239If the {\tt GLint64} type is required by a command, this will result in 240the following declarations: 241 242\begin{verbatim} 243#include <stddef.h> 244typedef ptrdiff_t GLintptr; 245\end{verbatim} 246 247 248\section{Enumerant Groups (\tag{groups} tag)} 249\label{tag:groups} 250 251The \tag{groups} tags contain individual \tag{group} tags describing 252some of the group annotations used for return and parameter types. 253 254\subsection{Attributes of \tag{groups} tags} 255 256None. 257 258\subsection{Contents of \tag{groups} tags} 259 260Each \tag{groups} block contains zero or more \tag{group} tags, in 261arbitrary order (although they are typically ordered by group name, to 262improve human readability). 263 264\subsection{Example of \tag{groups} tags} 265 266\begin{verbatim} 267<groups> 268 <group name="AccumOp"> 269 <enum name="GL_ACCUM"/> 270 </group> 271 272 <group name="AttribMask"> 273 <enum name="GL_ACCUM_BUFFER_BIT"/> 274 <enum name="GL_ALL_ATTRIB_BITS"/> 275 </group> 276</groups> 277\end{verbatim} 278 279 280\section{Enumerant Group (\tag{group} tag)} 281\label{tag:group} 282 283Each \tag{group} tag defines a single group annotation. 284 285\subsection{Attributes of \tag{group} tags} 286 287\begin{itemize} 288\item \attr{name} - group name, an arbitrary string for grouping a set 289 of enums together within a broader namespace. 290\end{itemize} 291 292\subsection{Contents of \tag{group} tags} 293 294\tag{group} tags may contain zero or more \tag{enum} tags. Each 295\tag{enum} tag may contain only a \attr{name} attribute, which should 296correspond to a \tag{enum} definition in an \tag{enums} block. 297 298\subsection{Meaning of \tag{group} tags} 299\label{tag:group:meaning} 300 301If a \tag{proto} or \tag{param} tag of a \tag{command} has a 302\attr{group} attribute defined, and that attribute matches a \tag{group} 303name, then the return type or parameter type is considered to be 304constrained to values defined by the corresponding \tag{group}. C 305language bindings do not attempt to enforce this constraint in any way, 306but other language bindings may try to do so. 307 308 309\section{Enumerant Blocks (\tag{enums} tag)} 310\label{tag:enums} 311 312The \tag{enums} tags contain individual \tag{enum} tags describing each of the 313token (enumerant) names used in the API. 314 315\subsection{Attributes of \tag{enums} tags} 316 317\begin{itemize} 318\item \attr{namespace} - a string for grouping many different enums 319 together, currently unused but typically something like \code{GL} 320 for all enums in the OpenGL / OpenGL ES shared namespace. Multiple 321 \tag{enums} tags can share the same namespace. 322\item \attr{type} - a string describing the data type of the values of 323 this group of enums, currently unused. The only string used at 324 present in the is \code{bitmask}. 325\item \attr{start}, \attr{end} - integers defining the start and end of 326 a reserved range of enumerants for a particular vendor or purpose. 327 \attr{start} must be $\leq$ \attr{end}. These fields define formal 328 enumerant allocations within a namespace, and are made by the 329 Khronos Registrar on request from implementers following the enum 330 allocation policy. 331\item \attr{vendor} - string describing the vendor or purposes to whom a 332 reserved range of enumerants is allocated. 333\item \attr{comment} - arbitrary string (unused) 334\end{itemize} 335 336\subsection{Contents of \tag{enums} tags} 337 338Each \tag{enums} block contains zero or more \tag{enum} and \tag{unused} 339tags, in arbitrary order (although they are typically ordered by sorting 340on enumerant values, to improve human readability). 341 342\subsection{Example of \tag{enums} tags} 343 344\begin{verbatim} 345<enums namespace="AttribMask" type="bitmask"> 346 <enum value="0x00000001" name="GL_CURRENT_BIT" /> 347 <enum value="0x00000002" name="GL_POINT_BIT" /> 348</enums> 349<enums namespace="GL" start="0x80E0" end="0x810F" vendor="MS"> 350 <enum value="0x80E0" name="GL_BGR" /> 351 <unused start="0x80E1" end="0x810F" /> 352</enums> 353\end{verbatim} 354 355When processed into a C header, and assuming all these tokens were 356required, this results in 357 358\begin{verbatim} 359#define GL_CURRENT_BIT 0x00000001 360#define GL_POINT_BIT 0x00000001 361#define GL_BGR 0x80E0 362\end{verbatim} 363 364 365\section{Enumerants (\tag{enum} tag)} 366\label{tag:enum} 367 368Each \tag{enum} tag defines a single GL (or other API) token. 369 370\subsection{Attributes of \tag{enum} tags} 371 372\begin{itemize} 373\item \attr{value} - enumerant value, a legal C constant (usually a 374 hexadecimal integer). 375\item \attr{name} - enumerant name, a legal C preprocessor token name. 376\item \attr{api} - an API name which specializes this definition of the 377 named enum, so that different APIs may have different values for 378 the same token (used to address a few accidental incompatibilities 379 between GL and GL ES). 380\item \attr{type} - legal C suffix for the value to force it to a 381 specific type. Currently only \code{u} and \code{ull} are used, 382 for \code{unsigned} 32- and 64-bit integer values, respectively. 383 Separated from the \attr{value} field since this eases parsing and 384 sorting of values, and is rarely used. 385\item \attr{alias} - name of another enumerant this is an alias of, used 386 where token names have been changed as a result of profile changes 387 or for consistency purposes. An enumerant alias is simply a 388 different \attr{name} for the exact same \attr{value}. At present, 389 enumerants which are promoted from extension to core API status 390 are not tagged as aliases - just enumerants tagged as aliases in 391 the {\em Changed Tokens} sections of appendices to the OpenGL 392 Specification. This might change in the future. 393\end{itemize} 394 395\subsection{Contents of \tag{enum} tags} 396 397\tag{enum} tags have no allowed contents. All information is contained 398in the attributes. 399 400 401\section{Unused Enumerants (\tag{unused} tag)} 402\label{tag:unused} 403 404Each \tag{unused} tag defines a range of enumerants which is allocated, 405but not yet assigned to specific enums. This just tracks the unused 406values and is not needed for header generation. 407 408\subsection{Attributes of \tag{unused} tags} 409 410\begin{itemize} 411\item \attr{start}, \attr{end} - integers defining the start and end of 412 an unused range of enumerants. \attr{start} must be $\leq$ 413 \attr{end}. This range should not exceed the range reserved by the 414 surrounding \tag{enums} tag. 415\item \attr{vendor} - string describing the vendor or purposes to whom a 416 reserved range of enumerants is allocated. Usually identical to 417 the \attr{vendor} attribute of the surrounding \attr{enums} block. 418\item \attr{comment} - arbitrary string (unused) 419\end{itemize} 420 421\subsection{Contents of \tag{unused} tags} 422 423None. 424 425 426\section{Command Blocks (\tag{commands} tag)} 427\label{tag:commands} 428 429The \tag{commands} tag contains definitions of each of the functions 430(commands) used in the API. 431 432\subsection{Attributes of \tag{commands} tags} 433 434\begin{itemize} 435\item \attr{namespace} - a string defining the namespace in which 436 commands live, currently unused but typically something like 437 \code{GL}. 438\end{itemize} 439 440\subsection{Contents of \tag{commands} tags} 441 442Each \tag{commands} block contains zero or more \tag{command} tags, in 443arbitrary order (although they are typically ordered by sorting on the 444command name, to improve human readability). 445 446 447\section{Commands (\tag{command} tag)} 448\label{tag:command} 449 450The \tag{command} tag contains a structured definition of a single API 451command (function). 452 453\subsection{Attributes of \tag{command} tags} 454 455\begin{itemize} 456\item \attr{comment} - arbitrary string (unused). 457\end{itemize} 458 459\subsection{Contents of \tag{command} tags} 460 461\begin{itemize} 462\item \tag{proto} must be the first element, and is a tag defining the C 463 function prototype of a command as described below, up to the 464 function name but not including function parameters. 465\item \tag{param} elements for each command parameter follow, defining 466 its name and type, as described below. If a command takes no 467 arguments, it has no \tag{param} tags. 468\end{itemize} 469 470Following these elements, the remaining elements in a \tag{command} 471tag are optional and may be in any order: 472 473\begin{itemize} 474\item \tag{alias} has one attribute, \attr{name}, containing a string which is the 475 name of another command this command is an alias of, used when 476 promoting a function from extension to ARB or ARB to API status. A 477 command alias describes the case where there are two function 478 names which resolve to the {\bf same} client library code, so (for 479 example) the case where a command is promoted but is also given 480 different GLX protocol would {\bf not} be an alias in this sense. 481\item \tag{vecequiv} has one attribute, \attr{name}, containing a string which is 482 the name of another command which is the {\em vector equivalent} 483 of this command. For example, the vector equivalent of 484 \code{glVertex3f} is \code{glVertex3fv}. 485\item \tag{glx} defines GLX protocol information for this command, as 486 described below. Many GL commands don't have GLX protocol defined, 487 and other APIs such as EGL and WGL don't use GLX at all. 488\end{itemize} 489 490 491\subsection{Command prototype (\tag{proto} tags)} 492\label{tag:command:proto} 493 494The \tag{proto} tag defines the return type and name of a command. 495 496\subsubsection{Attributes of \tag{proto} tags} 497 498\begin{itemize} 499\item \attr{group} - group name, an arbitrary string. 500\end{itemize} 501 502If the group name is defined, it may be interpreted as described in 503section~\ref{tag:group:meaning}. 504 505\subsubsection{Contents of \tag{proto} tags} 506 507The text elements of a \tag{proto} tag, with all other tags removed, is 508legal C code describing the return type and name of a command. In addition 509it may contain two semantic tags: 510 511\begin{itemize} 512\item The \tag{ptype} tag is optional, and contains text which is a 513 valid type name found in \tag{type} tag, and indicates that this 514 type must be previously defined for the definition of the command 515 to succeed. Builtin C types, and any derived types which are 516 expected to be found in other header files, should not be wrapped 517 in \tag{ptype} tags. 518\item The \tag{name} tag is required, and contains the command name 519 being described. 520\end{itemize} 521 522\subsection{Command parameter (\tag{param} tags)} 523\label{tag:command:param} 524 525The \tag{param} tag defines the type and name of a parameter. 526 527\subsubsection{Attributes of \tag{param} tags} 528 529\begin{itemize} 530\item \attr{group} - group name, an arbitrary string. 531\item \attr{len} - parameter length, either an integer specifying the 532 number of elements of the parameter \tag{ptype}, or a complex 533 string expression with poorly defined syntax, usually representing 534 a length that is computed as a combination of other command 535 parameter values, and possibly current GL state as well. 536\end{itemize} 537 538If the group name is defined, it may be interpreted as described in 539section~\ref{tag:group:meaning}. 540 541\subsubsection{Contents of \tag{param} tags} 542 543The text elements of a \tag{param} tag, with all other tags removed, is 544legal C code describing the type and name of a function parameter. In 545addition it may contain two semantic tags: 546 547\begin{itemize} 548\item The \tag{ptype} tag is optional, and contains text which is a 549 valid type name found in \tag{type} tag, and indicates that this 550 type must be previously defined for the definition of the command 551 to succeed. Builtin C types, and any derived types which are 552 expected to be found in other header files, should not be wrapped 553 in \tag{ptype} tags. 554\item The \tag{name} tag is required, and contains the command name 555 being described. 556\end{itemize} 557 558\subsection{Example of a \tag{commands} tag} 559 560\begin{verbatim} 561<commands> 562 <command> 563 <proto>void <name>glBeginConditionalRenderNV</name></proto> 564 <param><ptype>GLuint</ptype> <name>id</name></param> 565 <param><ptype>GLenum</ptype> <name>mode</name></param> 566 <alias name="glBeginConditionalRender" /> 567 <glx type="render" opcode="348" /> 568 </command> 569</commands> 570\end{verbatim} 571 572When processed into a C header, this results in 573 574\begin{verbatim} 575void glBeginConditionalRenderNV(GLuint id, GLenum mode); 576\end{verbatim} 577 578 579\section{API Features / Versions (\tag{feature} tag)} 580\label{tag:feature} 581 582API features are described in individual \tag{feature} tags. A feature 583is the set of interfaces (enumerants and commands) defined by a 584particular API and version, such as OpenGL 4.0 or OpenGL ES 3.0, and 585includes all API profiles of that version. 586 587\subsection{Attributes of \tag{feature} tags} 588 589\begin{itemize} 590\item \attr{api} - API name this feature is for (see 591 section~\ref{schema:apiname}), such as \code{gl} or \code{gles2}. 592\item \attr{name} - version name, used as the C preprocessor token under 593 which the version's interfaces are protected against multiple 594 inclusion. Example: \code{GL\_VERSION\_4\_2}. 595\item \attr{protect} - an additional preprocessor token used to protect 596 a feature definition. Usually another feature or extension 597 \attr{name}. Rarely used, for odd circumstances where the 598 definition of a feature or extension requires another to be 599 defined first. 600\item \attr{number} - feature version number, usually a string 601 interpreted as $majorNumber.minorNumber$. Example: \code{4.2}. 602\item \attr{comment} - arbitrary string (unused) 603\end{itemize} 604 605\subsection{Contents of \tag{feature} tags} 606 607Zero or more \tag{require} and \tag{remove} tags (see 608section~\ref{tag:required}), in arbitrary order. Each tag describes a 609set of interfaces that is respectively required for, or removed from, 610this feature, as described below. 611 612\subsection{Example of a \tag{feature} tag} 613 614\begin{verbatim} 615<feature api="gl" name="GL_VERSION_3_0" number="3.0"> 616 <require> 617 <enum name="GL_COMPARE_REF_TO_TEXTURE" /> 618 <enum name="GL_CLIP_DISTANCE0" /> 619 <command name="glEndTransformFeedback" /> 620 </require> 621 <require profile="compatibility"> 622 <enum name="GL_INDEX" /> 623 </require> 624</feature> 625\end{verbatim} 626 627When processed into a C header for the \code{compatibility} profile of 628OpenGL, this results in (assuming the usual definitions of these GL 629interfaces): 630 631\begin{verbatim} 632#ifndef GL_VERSION_3_0 633#define GL_VERSION_3_0 1 634#define GL_COMPARE_REF_TO_TEXTURE 0x884E 635#define GL_CLIP_DISTANCE0 0x3000 636#define GL_INDEX 0x8222 637typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); 638#ifdef GL_GLEXT_PROTOTYPES 639GLAPI void APIENTRY glEndTransformFeedback (void); 640#endif 641#endif /* GL_VERSION_3_0 */ 642\end{verbatim} 643 644If processed into a header for the \code{core} profile, the definition of 645\code{GL\_INDEX} would not appear. 646 647 648\section{Extension Blocks (\tag{extensions} tag)} 649\label{tag:extensions} 650 651The \tag{extensions} tag contains definitions of each of the extenions 652which are defined for the API. 653 654\subsection{Attributes of \tag{extensions} tags} 655 656None. 657 658\subsection{Contents of \tag{extensions} tags} 659 660Each \tag{extensions} block contains zero or more \tag{extension} tags, 661each describing an API extension, in arbitrary order (although they are 662typically ordered by sorting on the extension name, to improve human 663readability). 664 665 666\section{API Extensions (\tag{extension} tag)} 667\label{tag:extension} 668 669API extensions are described in individual \tag{extension} tags. An 670extension is the set of interfaces defined by a particular API extension 671specification, such as \code{ARB\_multitexture}. \tag{extension} is 672similar to \tag{feature}, but instead of having \attr{version} and 673\attr{profile} attributes, instead has a \attr{supported} attribute, 674which describes the set of API names which the extension can potentially 675be implemented against. 676 677\subsection{Attributes of \tag{extension} tags} 678 679\begin{itemize} 680\item \attr{supported} - a regular expression, with an implicit 681 \code{\^{}} and \code{\$} bracketing it, which should match the 682 \attr{api} tag of a set of \tag{feature} tags. 683\item \attr{protect} - an additional preprocessor token used to protect 684 an extension definition. Usually another feature or extension 685 \attr{name}. Rarely used, for odd circumstances where the 686 definition of an extension requires another to be defined first. 687\item \attr{comment} - arbitrary string (unused) 688\end{itemize} 689 690\subsection{Contents of \tag{extension} tags} 691 692Zero or more \tag{require} and \tag{remove} tags (see 693section~\ref{tag:required}), in arbitrary order. Each tag describes a 694set of interfaces that is respectively required for, or removed from, 695this extension, as described below. 696 697\subsection{Example of an \tag{extensions} tag} 698 699\begin{verbatim} 700<extensions> 701 <extension name="GL_ARB_robustness" supported="gl|glcore" > 702 <require> 703 <enum name="GL_NO_ERROR" /> 704 <command name="glGetGraphicsResetStatusARB" /> 705 </require> 706 <require api="gl" profile="compatibility"> 707 <command name="glGetnMapdvARB" /> 708 </require> 709 </extension> 710</extensions> 711\end{verbatim} 712 713The \attr{supported} attribute says that the extension can be supported for 714either the GL compatibility (\code{gl}) or GL core (\code{glcore}) API 715profiles, but not for other APIs. When processed into a C header for the 716\code{core} profile of OpenGL, this results in (assuming the usual 717definitions of these GL interfaces): 718 719\begin{verbatim} 720#ifndef GL_ARB_robustness 721#define GL_ARB_robustness 1 722#define GL_NO_ERROR 0 723typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); 724#ifdef GL_GLEXT_PROTOTYPES 725GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); 726#endif 727#endif /* GL_ARB_robustness */ 728\end{verbatim} 729 730 731\section{Required and Removed Interfaces (\tag{require} and \tag{remove} tags)} 732\label{tag:required} 733 734A \tag{require} block defines a set of interfaces (types, enumerants and 735commands) {\em required} by a \tag{feature} or \tag{extension}. A 736\tag{remove} block defines a set of interfaces {\em removed} by a 737\tag{feature} (this is primarily useful for the OpenGL core profile, 738which removed many interfaces - extensions should never remove 739interfaces, although this usage is allowed by the schema). Except for 740the tag name and behavior, the contents of \tag{require} and 741\tag{remove} tags are identical. 742 743\subsection{Attributes of \tag{require} and \tag{remove} tags} 744 745\begin{itemize} 746\item \attr{profile} - string name of an API profile. Interfaces in the 747 tag are only required (or removed) if the specified profile is 748 being generated. If not specified, interfaces are required (or 749 removed) for all API profiles. 750\item \attr{comment} - arbitrary string (unused) 751\item \attr{api} - an API name (see section~\ref{schema:apiname}). Interfaces 752 in the tag are only required (or removed) if the specified API is 753 being generated. If not specified, interfaces are required (or 754 removed) for all APIs. 755 756 {\bf The \attr{api} attribute is only supported inside 757 \tag{extension} tags,} since \tag{feature} tags already define a 758 specific API. 759\end{itemize} 760 761\subsection{Contents of \tag{require} and \tag{remove} tags} 762 763Zero or more of the following tags, in any order: 764 765\begin{itemize} 766\item \tag{command} specifies an required (or removed) command defined 767 in a \tag{commands} block. The tag has no content, but contains 768 elements: 769 770 \begin{itemize} 771 \item \attr{name} - name of the command (required). 772 \item \attr{comment} - arbitrary string (optional and unused). 773 \end{itemize} 774\item \tag{enum} specifies an required (or removed) enumerant defined in 775 a \tag{enums} block. The tag has no content, but contains 776 elements: 777 778 \begin{itemize} 779 \item \attr{name} - name of the enumerant (required). 780 \item \attr{comment} - arbitrary string (optional and unused). 781 \end{itemize} 782\item \tag{type} specifies a required (or removed) type defined in a 783 \tag{types} block. Most types are picked up implicitly by using 784 the \tag{ptype} tags of commands, but in a few cases, additional 785 types need to be specified explicitly (it is unlikely that a type 786 would ever be removed, although this usage is allowed by the 787 schema). The tag has no content, but contains elements: 788 789 \begin{itemize} 790 \item \attr{name} - name of the type (required). 791 \item \attr{comment} - arbitrary string (optional and unused). 792 \end{itemize} 793\end{itemize} 794 795 796\section{General Discussion} 797\label{general} 798 799 800\subsection{Stability of the XML Database and Schema} 801\label{general:stability} 802 803The new registry schema, scripts, and databases are evolving in response 804to feedback and to Khronos' own wishlist. This means the XML schema is 805subject to change, although most such change will probably be confined 806to adding attributes to existing tags. The XML databases such as 807\code{gl.xml} will evolve in response to schema changes, to new 808extensions and API versions, and to general cleanup, such as 809canonicalization of the XML or sorting of \tag{command} and 810\tag{extension} tags by name. Changes to the schema will be described in 811the change log of this document (see section~\ref{changelog}). Changes 812to the \code{.xml} files will be described in Subversion revision 813history. 814 815 816\subsection{Feature Enhancements to the Registry} 817\label{general:enhancements} 818 819There are lots of tools and additional tags that would make the XML 820format more expressive and the tools more capable. Khronos is open to 821hosting additional processing scripts for other purposes. We're hoping 822to be much more responsive to bugs filed in the Khronos public bugzilla 823now that there's a more modern and maintainable framework to build on. 824 825A partial wishlist follows: 826 827\begin{itemize} 828\item Enhance \tag{command} \tag{alias} tags to describe more relaxed 829 sorts of aliases, such as commands equivalent in behavior and 830 interface, but using different GLX protocol (this might be called 831 a {\em client-side alias} or something of the sort). 832\end{itemize} 833 834\subsection{Type Annotations and Relationship to \code{.spec} Files} 835\label{general:annotations} 836 837The initial releases of the XML Registry did not include type annotation 838and array length information from the old \code{.spec} files, which 839generated a number of complaints from people writing bindings of OpenGL 840to languages other than C. The majority of these annotations have now 841been added to the XML, in the form of \tag{group} tags (see 842section~\ref{tag:group}) defining groups of related enumerants, 843\attr{group} attributes on \tag{proto} and \tag{param} tags specifying 844that the corresponding return type belongs to a group, and \attr{len} 845attributes on \tag{param} tags specifying the array length of the 846corresponding parameter. 847 848There are many caveats regarding these annotations. For the most part 849they date from SGI's OpenGL 1.1 implementation, and have not been 850updated. The defined \tag{group}s therefore do not cover many API 851parameters which {\bf could} be given a group, and in many cases, the 852defined \tag{group}s have not been updated to add new enumerants from 853later versions of OpenGL and OpenGL extensions. The group names are 854often somewhat misleading (with imbedded vendor extension tags, while 855the corresponding features have been promoted). 856 857The \tag{group}s added to \code{gl.xml} are the enumerant groups defined 858in \code{enum.spec}, and \code{enumext.spec}. Many additional group 859names were used in the annotations in \code{gl.spec}, and they 860fall in several categories discussed below. 861 862 863\subsubsection{Simple API Type Aliases} 864 865Group names that were simply an alias for a GL type have been left 866entirely out of \code{gl.xml}, since they offer no useful additional 867information. 868 869For example, a parameter described as \code{UInt32} in \code{gl.spec} is 870not annotated with \code{group="UInt32"} in \code{gl.xml}, because this 871offers no information about the parameter not already present in its 872declaration as \code{<ptype>GLuint</ptype>}. 873 874A few examples of such groups are \code{cl\_context}, 875\code{handleARB}, \code{Int32}, and \code{sync}. 876 877 878\subsubsection{Numeric Constraints} 879 880Group names representing some type of numerical constraint on a value 881are retained in \tag{proto} and \tag{param} \attr{group} attributes, but 882no definition exists. This is because the existing \tag{group} mechanism 883can only describe constraints to specific enumerant names. 884 885This is not a regression relative to the \code{.spec} files, which also 886did not describe the meaning of these groups. 887 888A few examples of such groups are \code{CheckedFloat32}, 889\code{ClampedFixed}, and \code{CoordD}. 890 891 892\subsubsection{GL Object Names} 893 894Group names representing an object name obtained from e.g. a 895\code{glGen*} command, such as a display list name, are retained in in 896\tag{proto} and \tag{param} \attr{group} attributes, but no definition 897exists. This is because the existing \tag{group} mechanism can only 898describe constraints to specific enumerant names. 899 900This is not a regression relative to the \code{.spec} files, which also 901did not describe the meaning of these groups. 902 903A few examples of such groups are \code{List} and \code{Path}. 904 905 906\subsubsection{Groups Not Defined Yet} 907 908Group names representing enumerant groups which were not defined in 909\code{enum.spec} and \code{enumext.spec} are retained in \tag{proto} and 910\tag{param} \attr{group} attributes, but no definition exists. Such 911groups usually are a result of vendors contributing \code{gl.spec} 912entries for an extension without contributing corresponding 913\code{enum.spec} entries. 914 915This is not a regression relative to the \code{.spec} files, which also 916did not describe the meaning of these groups. 917 918A few examples of such groups are \code{ArrayObjectPNameATI}, 919\code{BinormalPointerTypeEXT}, and \code{SpriteParameterNameSGIX}. 920 921 922\subsubsection{Other Groups} 923 924There are probably a few groups which are present in \code{gl.xml} but 925should not be. These can be gradually cleaned up over time. 926 927 928\subsubsection{Validating Groups} 929 930The \code{genheaders.py} script has been enhanced to allow validating 931groups during header generation. Invoking it with the 932\code{-validate} option, for example via: 933 934\code{\$ genheaders.py -validate -registry gl.xml} 935 936\noindent will generate a text dump on standard output showing all 937parameter type \attr{group} attributes which do {\bf not} have 938corresponding \tag{group} tags. 939 940 941\section{Change Log} 942\label{changelog} 943 944\begin{itemize} 945\item 2017-01-20 - Update for the move to the new github repository. 946\item 2014-06-16 - Add \tag{vendor} attribute to \tag{unused} tags. 947\item 2013-09-17 - Add \tag{comment} attribute to \tag{command} tags 948 within \tag{commands}. 949\item 2013-06-24 - Add \tag{groups} and \tag{group} tags, renamed 950 \tag{enums} attribute \attr{class} to \attr{group}, and add 951 parameter type annotation attributes \attr{group} and \attr{len} 952 to both \tag{proto} and \tag{param}. Add 953 section~\ref{general:annotations} discussing limitations of these 954 annotations. Still need to add examples of the annotation 955 attributes. 956\item 2013-06-19 - Added \tag{extensions} tag block as a wrapper around 957 groups of \tag{extension} tags, to ease XML transformations such 958 as sorting extensions by name. 959\item 2013-06-14 - Expanded description of tags, better formatting 960\item 2013-06-12 - First release, text file format 961\end{itemize} 962 963\input{readme.ind} 964 965% \printindex 966 967\end{document} 968