1// Copyright 2014-2022 The Khronos Group Inc. 2// SPDX-License-Identifier: CC-BY-4.0 3 4= Vulkan^(R)^ Specification Build Instructions and Notes 5:toc2: 6:toclevels: 2 7 8ifdef::env-github[] 9:note-caption: :information_source: 10endif::[] 11 12 13[[intro]] 14== Introduction 15 16This README describes how to build the Vulkan API specification, reference 17pages, and/or other related targets. 18 19It documents how to set up your build environment, build steps and targets, 20and contains some troubleshooting advice. 21 22 23[[building]] 24== Building The Spec 25 26First, clone the Khronos Github repository containing the Vulkan 27specification to your local Linux, Windows, or Mac PC. 28The repository is located at https://github.com/KhronosGroup/Vulkan-Docs/. 29 30Next, install all the necessary build tools (see <<depends,Software 31Dependencies>> below). 32If you are using the <<depends-docker, Khronos-Provided Docker Image>>, 33which we strongly recommend, one way to build using the image (assuming a 34Linux docker host) is: 35 36 $ scripts/runDocker 37 38executed from the specification repository root. 39 40`runDocker` runs the Docker image with the cloned repository mounted under 41/vulkan and accesses it as a specified user (set to your own user and group 42ID), so that it does not get filled with files owned by another user. 43The script leaves you inside a bash shell in the running image. 44Execute the commands: 45 46 $ cd /vulkan 47 $ ./makeSpec -spec core html 48 49to build an HTML5 specification output for the core Vulkan 1.3 50specification, with no extensions included, or 51 52 $ cd /vulkan 53 $ ./makeSpec -spec all all 54 55to build the spec targets `html`, `pdf`, `styleguide`, `registry`, 56`manhtmlpages`, and `allchecks`, with *all* registered extensions included. 57 58There are many other ways of using the image, including inside a Continuous 59Integration pipeline; locally with persistent Docker volume storage of the 60repository; and so on. 61 62If you are not using our Docker image to build with, and you have a 63<<depends-nondocker, Non-Docker Build Environment>> with the entire 64toolchain installed, you can just invoke the same `make` commands from the 65repository root. 66 67[NOTE] 68.Note 69==== 70You can modify the `runDocker` script to change the `docker` command-line 71options, but it is important to always use the Docker image specified in 72that script, so you have the latest version of the spec toolchain. 73==== 74 75[NOTE] 76.Note 77==== 78 * While it is possible to invoke `make` directly, this is rarely 79 appropriate or useful. 80 Usually dozens to hundreds of build options must be set to specify the 81 desired set of extensions to include in the specification. 82 The `makeSpec` python script, which is discussed in more detail 83 <<building-extensions, below>>, simplifies this process for common 84 cases. 85 * The `all` target takes a long time to run, and generates outputs that 86 are irrelevant for most users. 87 The `html` target just generates the HTML output, which is often all 88 that is needed for spec bugfixes not involving extensions. 89 * The default `make` options build a Vulkan 1.3 specification with no 90 optional extensions. 91 * The `validusage` target is not built as part of the `all` target, due to 92 it needing to be built with all extensions enabled (`-spec all`). 93 Building the `validusage` target will fail otherwise. 94==== 95 96These targets generate a variety of output documents in the directory 97specified by the Makefile variable `$(OUTDIR)` (by default, `out/`). 98The checked-in file `out/index.html` links to all these 99targets, or they can individually be found as follows: 100 101Vulkan Specification:: 102 * `html` -- Single-file HTML5 in `$(OUTDIR)/html/vkspec.html`, and KaTeX 103 dependency in $(OUTDIR)/katex 104 * `chunked` -- Chunked HTML5 in `$(OUTDIR)/html/chap?.html` 105 * `pdf` -- PDF in `$(OUTDIR)/pdf/vkspec.pdf` 106"`styleguide`" (Vulkan Documentation and Extensions: Procedures and Conventions):: 107 * `styleguide` -- Single-file HTML5 in `$(OUTDIR)/styleguide.html` 108XML Registry schema document:: 109 * `registry` -- Single-file HTML5 in `$(OUTDIR)/registry.html` 110<<building-diff,Diff spec>>:: 111 * `diff_html` -- Single-file HTML5 in `$(OUTDIR)/html/diff.html` 112<<refpages,Reference pages>>:: 113 * `manhtmlpages` -- File-per-entry-point HTML in `$(OUTDIR)/man/html/*`. 114 Must be built with all extensions enabled (using `makeSpec -spec all`). 115<<validation-scripts,Validator output>>:: 116 * None at present. The `allchecks` target writes to standard output unless 117 the underlying script is given additional options. 118Valid usage database:: 119 * `validusage` - json database of all valid usage statements in the 120 specification. Must be built with `./makeAllExts` (for now). 121 Output in `$(OUTDIR)/validation/validusage.json`. 122 A validated schema for the output of this is stored in 123 `$(CURDIR)/config/vu-to-json/vu_schema.json` 124 125Once you have the basic build working, an appropriate parallelization 126option, such as `-j 8`, should significantly speed up the reference page 127builds. 128 129If you encounter problems refer to the <<troubleshooting>> section. 130 131 132[[building-versions]] 133=== Building Specifications For Different API Versions 134 135The `Makefile` defaults to building a Vulkan 1.3 specification. 136This is controlled by Asciidoctor attributes passed in the Makefile variable 137`$(VERSIONS)` 138To instead build a Vulkan 1.1 specification, pass 139 140---- 141VERSIONS="VK_VERSION_1_0 VK_VERSION_1_1" 142---- 143 144on the `makeSpec` command line. 145 146 147[[building-extensions]] 148=== Building With Extensions Included 149 150Extensions are defined in the same source as the core Specification, but 151are only conditionally included in the output. 152https://asciidoctor.org/docs/user-manual/#attributes[Asciidoctor attributes] 153of the same name as the extension are used to define whether the extension 154is included or not -- defining such an attribute will cause the output to 155include the text for that extension. 156 157When building the specification, the extensions included are those specified 158as a space-separated list of extension names (e.g. `VK_KHR_surface`) in the 159Makefile variable `$(EXTENSIONS)`, usually set on the make command line. 160When changing the list of extensions, it is critical to remove all generated 161files using the `clean_generated` Makefile target, as the contents of 162generated files depends on `$(EXTENSIONS)`. 163 164The `makeSpec` wrapper script can clean generated files and then build one 165or more specification targets for a set of explicitly specified extensions, 166including all implicit extension dependencies of that set. 167It accepts these options: 168 169 * -clean - remove generated targets before building 170 * -v - print actions as well as executing them 171 * -n - print actions without executing them 172 * -genpath *path* - specify path to generated files (default `gen`) 173 * -spec *type* - build with specified sets of extensions. 174 *type* may be 175 ** *core* - no extensions added (default if not specified) 176 ** *khr* - all KHR extensions added 177 ** *all* - all registered extensions added 178 * -extension *extname* - build with specified extension included, 179 as well as the set specified by `-spec`. 180 Can be given multiple times. 181 * All remaining targets are arbitrary `make` options or 182 targets in the Makefile. 183 184The `target(s)` passed to these scripts are arbitrary `make` options, and 185can be used to set Makefile variables and options discussed above, as well 186as specify actual build targets. 187For example, to build the HTML specification with all KHR extensions 188included as well as a single vendor extension: 189 190---- 191$ ./makeSpec -clean -spec khr -extension VK_EXT_debug_report html 192---- 193 194The scripts `makeAllExts`, `makeKHR`, and `makeExt` set appropriate options 195and invoke `makeSpec`, for backwards compatibility, but are no longer used 196by Khronos. 197 198The Makefile variable `$(APITITLE)` defines an additional string which is 199appended to the specification title. 200When building with extensions enabled, this should be set to something like 201`(with extension VK_extension_name)`. 202The `makeSpec` script already does this. 203 204The reference pages (the `manhtmlpages` target) must be built using the 205`-spec all` option; there are markup and scripting issues which will 206probably cause any more restricted set of refpages to fail to build. 207 208 209[[building-diff]] 210==== Building A Highlighted Extension Diff 211 212The `diff_html` target in the Makefile can be used to generate a version of 213the specification which highlights changes made to the specification by the 214inclusion of a particular set of extensions. 215 216Extensions in the Makefile variable `$(EXTENSIONS)` define the base 217extensions to be enabled by the specification, and these will not be 218highlighted in the output. 219Extensions in the Makefile variable `$(DIFFEXTENSIONS)` define the set of 220extensions whose changes to the text will be highlighted when they are 221enabled. 222Any extensions in both variables will be treated as if they were only 223included in `$(DIFFEXTENSIONS)`. 224`$(DIFFEXTENSIONS)` can be set when using the `makeSpec` script described 225above. 226 227In the resulting HTML document, content that has been added by one of the 228extensions will be highlighted with a lime background, and content that was 229removed will be highlighted with a pink background. 230Each section has an anchor of `#differenceN`, with an arrow (=>) at the end 231of each section which links to the next difference section. 232The first diff section is `#difference1`. 233 234[NOTE] 235.Note 236==== 237This output is not without errors. 238It may instead result in visible `+++[.added]##content##+++` and 239`+++[.removed]##content##+++`, and so also highlights not being rendered. 240But such visible markup still correctly encapsulates the modified content. 241==== 242 243 244[[building-test]] 245=== Alternate and Test Builds 246 247If you are just testing Asciidoctor formatting, macros, stylesheets, etc., 248you may want to edit `vkspec.adoc` to just include your test code. 249The asciidoctor HTML build is very fast, even for the whole Specification, 250but PDF builds take several minutes. 251 252 253=== Images Used In The Specification 254 255All images used in the specification are in the `images/` directory in the 256SVG format, and were created with Inkscape. 257We recommend using Inkscape to modify or create new images, due to problems 258using SVG files created by some other tools; especially in the PDF builds. 259 260 261[[validation-scripts]] 262=== Validation Scripts 263 264The `allchecks` Makefile target runs a Python script that looks for markup 265errors, missing interfaces, macro misuse, and inconsistencies in the 266specification text. 267This script is necessarily heuristic, since it is dealing with lots of 268hand-written material, but it identifies many problems and can suggest 269solutions. 270This script is also run as part of the CI tests in the internal Khronos 271gitlab repository. 272 273 274[[macros]] 275== Our Asciidoctor Macros 276 277We use many custom Ruby macros in the reference pages and API spec 278Asciidoctor sources. 279The validator scripts rely on these macros as part of their checks. 280and you should use the macros whenever referring to an API command, struct, 281token, or enum name, so the documents are semantically tagged and more 282easily verifiable. 283 284The supported macros are defined in the `config/spec-macros/extension.rb` 285asciidoctor extension script. 286 287The tags used are described in the 288link:https://registry.khronos.org/vulkan/specs/1.1/styleguide.html[style 289guide] (generated from `styleguide.adoc`). 290 291We (may) eventually tool up the spec and reference pages to the point that 292anywhere there is a type or token referred to, clicking on (or perhaps 293hovering over) it in the HTML view will take reader to the definition of 294that type/token. 295That will take some more plumbing work to tag the stuff in the autogenerated 296include files, and do something sensible in the spec (e.g. resolve links to 297internal references). 298 299Most of these macros deeply need more intuitive names. 300 301 302[[refpages]] 303== Reference Pages 304 305The reference pages are extracted from the API Specification source, which 306has been tagged to help identify boundaries of language talking about 307different commands, structures, enumerants, and other types. 308A set of Python scripts extract and lightly massage the relevant tagged 309language into corresponding reference page sources. 310 311To regenerate the reference page sources from scratch yourself, execute: 312 313---- 314./makeSpec -spec all refpages 315---- 316 317The `genRef.py` script will generate many warnings, but most are just 318reminders that some pages are automatically generated. 319If everything is working correctly, all the `$(GENERATED)/refpage/*.adoc` 320files will be regenerated, but their contents will not change. 321 322If you add new API features to the Specification in a branch, make sure that 323the commands have the required tagging and that reference pages are 324generated for them, and build properly. 325 326When executing the `manhtmlpages` target in the Makefile, after building 327HTML versions of all reference pages extracted from the spec, symbolic links 328from aliases to the reference page for the API they alias will also be 329created. 330 331 332[[styles]] 333== Our stylesheets 334 335We use an HTML stylesheet `config/khronos.css` derived from the 336https://asciidoctor.org/docs/produce-custom-themes-using-asciidoctor-stylesheet-factory/[Asciidoctor 337stylesheet factory] "`colony`" theme, with the default Arial font family 338replaced by the sans-serif https://en.wikipedia.org/wiki/Noto_fonts[Noto 339font family]. 340 341 342[[styleguide]] 343== Vulkan Style Guide 344 345If you are writing new spec language or modifying existing language, see the 346link:https://registry.khronos.org/vulkan/specs/1.2/styleguide.html["`style 347guide`"] (formally titled "`Vulkan Documentation and Extensions: Procedures 348and Conventions`") document for details of our asciidoctor macros, 349extensions, mathematical equation markup, writing style, etc. 350 351 352[[depends]] 353== Software Dependencies 354 355This section describes the software components used by the Vulkan spec 356toolchain. 357 358In the past, we previously specified package versions and instructions for 359installing the toolchain in multiple desktop environments including Linux, 360MacOS X, and Microsoft Windows. 361The underlying components evolve rapidly, and we have not kept those 362instructions up to date. 363 364 365[[depends-docker]] 366=== Khronos-Provided Docker Image 367 368Khronos has published a Docker image containing a Debian Linux distribution 369with the entire toolchain preinstalled. 370 371We will occasionally update this image if needed, and we recommend people 372needing to build from this repository use the Docker image. 373 374Docker installation is beyond the scope of this document. 375Refer to link:https://docs.docker.com/get-docker/[the Docker website] for 376information about installing Docker on Linux, Windows, and MacOS X. 377 378The build image is *named* `khronosgroup/docker-images:asciidoctor-spec`. 379However, due to local and CI caching problems when this image is updated on 380dockerhub, we use the SHA256 of the latest image update, rather than the 381image name. The SHA256 can be determined from 382 383 $ git grep -h sha256: .gitlab-ci.yml 384 385which will print a line like 386 387 image: khronosgroup/docker-images@sha256:9cfd1add08df752a6b07156b1f67ba203b88b2f520f75f0f042d77efdff318a0 388 389Everything following `image: ` is the <imagename> to use. The first time you 390try to run Docker with this <imagename>, as is done by the `runDocker` 391script described above under <<building, Building the Spec>>, the image will 392be pulled from Dockerhub and cached locally on your machine. 393 394This image is used to build Specification output documents or other Makefile 395targets. 396 397[NOTE] 398.Note 399==== 400When we update the image on Dockerhub, it is to add new components or update 401versions of components used in the specification toolchain. 402To save space, you may want to periodically purge old images using `docker 403images` and `docker rmi -f`. 404==== 405 406 407[[depends-nondocker]] 408=== Non-Docker Build Environments 409 410We do not actively support building outside of our Docker image, but it is 411straightforward to reproduce our toolchain in a Debian (or similar APT-based 412Linux) distribution by executing the same steps as the 413link:https://github.com/KhronosGroup/DockerContainers/blob/master/asciidoctor-spec.dockerfile[Dockerfile] 414used to build our Docker image. 415 416It should be possible to apply the same steps in a Windows Subsystem for 417Linux (WSL2) environment on Windows 10, as well. 418 419For other native environments, such as MacOS X and older Unix-like 420environments for Windows such as MinGW and Cygwin, we provided instructions 421in older versions of this document. 422While those instructions are out of date and have been removed from current 423versions of this document, you may be able to make use of 424link:https://github.com/KhronosGroup/Vulkan-Docs/blob/v1.2.135/BUILD.adoc#depends[the 425version of BUILD.adoc in the v1.2.135 repository tag] 426 427[NOTE] 428.Note 429==== 430While you do not have to use our Docker image, we cannot support every 431possible build environment. 432The Docker image is a straightforward way to build the specification in most 433modern desktop environments, without needing to install and update the spec 434toolchain yourself. 435==== 436 437 438[[history]] 439== Revision History 440 441 * 2022-10-11 - Update descriptions of using the Docker image to use the 442 `runDocker` script and the same SHA256 of the latest image as used by 443 CI. 444 * 2021-03-12 - Use the new Docker image. 445 * 2020-07-15 - Update to use `makeSpec` instead of `makeAllExts`. 446 * 2020-03-23 - Document Khronos' published Docker image for building the 447 spec, and remove all platform-specific instructions. 448 * 2018-12-04 - Update Rbenv and ruby gem installation instructions and 449 package dependencies for Linux and Ubuntu/Windows 10. 450 * 2018-10-25 - Update Troubleshooting, and Windows and Linux build. Plus 451 random editing. 452 * 2018-03-13 - Rename to BUILD.adoc and update for new directory 453 structure. 454 * 2018-03-05 - Update README for Vulkan 1.1 release. 455 * 2017-03-20 - Add description of prawn versioning problem and how to fix 456 it. 457 * 2017-03-06 - Add description of ruby-enum versioning problem and how to 458 fix it. 459 * 2017-02-13 - Move some comments here from ../../../README.md. Tweak 460 asciidoctor markup to more clearly delineate shell command blocks. 461 * 2017-02-10 - Add more Ruby installation guidelines and reflow the 462 document in accordance with the style guide. 463 * 2017-01-31 - Add rbenv instructions and update the README elsewhere. 464 * 2017-01-16 - Modified dependencies for Asciidoctor 465 * 2017-01-06 - Replace MathJax with KaTeX. 466 * 2016-08-25 - Update for the single-branch model. 467 * 2016-07-10 - Update for current state of spec and ref page generation. 468 * 2015-11-11 - Add new can: etc. 469 macros and DBLATEXPREFIX variable. 470 * 2015-09-21 - Convert document to asciidoc and rename to README.md in the 471 hope the gitlab browser will render it in some fashion. 472 * 2015-09-21 - Add descriptions of LaTeX and MathJax math support for all 473 output formats. 474 * 2015-09-02 - Added Cygwin package info. 475 * 2015-09-02 - Initial version documenting macros, required toolchain 476 components and versions, etc. 477