Clarify placement of different versioned specs
[platform/upstream/SPIRV-Headers.git] / README.md
1 # SPIR-V Headers
2
3 This repository contains machine-readable files from the
4 [SPIR-V Registry](https://www.khronos.org/registry/spir-v/).
5 This includes:
6
7 * Header files for various languages.
8 * JSON files describing the grammar for the SPIR-V core instruction set,
9   and for the GLSL.std.450 and OpenCL extended instruction sets.
10 * The XML registry file.
11
12 Under the [include](include) directory, header files are provided according to
13 their own version.  Only major and minor version numbers count.
14 For example, the headers for SPIR-V 1.1 are in
15 [include/spirv/1.1](include/spirv/1.1).  Also, the 1.0 versions of the
16 GLSL.std.450 and OpenCL extended instruction sets are in
17 [include/spirv/1.0](include/spirv/1.0).
18
19 In contrast, the XML registry file has a linear history, so it is
20 not tied to SPIR-V specification versions.
21
22 ## How is this repository updated?
23
24 When a new version or revision of the SPIR-V header files are published,
25 the SPIR Working Group will push new commits onto master, updating
26 the files under [include](include).
27 A newer revision of a header file always replaces an older revision of
28 the same version.  For example, verison 1.0 Rev 4 of `spirv.h` is placed in
29 `include/spirv/1.0/spirv.h` and if there is a Rev 5, then it will be placed
30 in the same location.
31
32 The SPIR-V XML registry file is updated by the Khronos registrar whenever
33 a new enum range is allocated.
34
35 In particular, pull requests that update header files will not be accepted.
36 Issues with the header files should be filed in the
37 [Khronos public bugzilla database](https://www.khronos.org/bugzilla/),
38 against the Specification component of the SPIR-V product.
39
40 ## How to install the headers
41
42 ```
43 mkdir build
44 cd build
45 cmake ..
46 # Linux
47 cmake --build . --target install-headers
48 # Windows
49 cmake --build . --config Debug --target install-headers
50 ```
51
52 Then, for example, you will have `/usr/local/include/spirv/1.0/spirv.h`
53
54 If you want to install them somewhere else, then use
55 `-DCMAKE_INSTALL_PREFIX=/other/path` on the first `cmake` command.
56
57 ## Using the headers without installing
58
59 A CMake-based project can use the headers without installing, as follows:
60
61 1. Add an `add_subdirectory` directive to include this source tree.
62 2. Use `${SPIRV-Headers_SOURCE_DIR}/include}` in a `target_include_directories`
63    directive.
64 3. In your C or C++ source code use `#include` directives that explicitly mention
65    the `spirv` path component.  For example the following uses SPIR-V 1.1
66    core instructions, and the 1.0 versions of the GLSL.std.450 and OpenCL
67    extended instructions.
68 ```
69 #include "spirv/1.0/GLSL.std.450.h"
70 #include "spirv/1.0/OpenCL.std.h"
71 #include "spirv/1.1/spirv.hpp"
72 ```
73
74 See also the [example](example/) subdirectory.  But since that example is
75 *inside* this repostory, it doesn't use and `add_subdirectory` directive.
76
77 ## FAQ
78
79 * *How are different versions published?*
80
81   All versions are present in the master branch of the repository.
82   They are located in different subdirectories under
83   [include/spirv](include/spirv), where the subdirectory at that
84   level encodes the major and minor version number of the relevant spec.
85
86   An application should consciously select the targeted spec version
87   number, by naming the specific version in its `#include` directives,
88   as above and in the examples.
89
90 * *How do you handle the evolution of extended instruction sets?*
91
92   Extended instruction sets evolve asynchronously from the core spec.
93   Right now there is only a single version of both the GLSL and OpenCL
94   headers.  So we don't yet have a problematic example to resolve.
95
96 ## License
97 <a name="license"></a>
98 ```
99 Copyright (c) 2015-2016 The Khronos Group Inc.
100
101 Permission is hereby granted, free of charge, to any person obtaining a
102 copy of this software and/or associated documentation files (the
103 "Materials"), to deal in the Materials without restriction, including
104 without limitation the rights to use, copy, modify, merge, publish,
105 distribute, sublicense, and/or sell copies of the Materials, and to
106 permit persons to whom the Materials are furnished to do so, subject to
107 the following conditions:
108
109 The above copyright notice and this permission notice shall be included
110 in all copies or substantial portions of the Materials.
111
112 MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
113 KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
114 SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
115    https://www.khronos.org/registry/
116
117 THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
118 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
119 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
120 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
121 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
122 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
123 MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
124 ```