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