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