Add spec file and manifect file
[platform/upstream/SPIRV-Headers.git] / README.md
1 # SPIR-V Headers
2
3 This repository contains machine-readable files for 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 the extended instruction sets.
10 * The XML registry file.
11 * A tool to build the headers from the JSON grammar.
12
13 Headers are provided in the [include](include) directory, with up-to-date
14 headers in the `unified1` subdirectory. Older headers are provided according to
15 their version.
16
17 In contrast, the XML registry file has a linear history, so it is
18 not tied to SPIR-V specification versions.
19
20 ## How is this repository updated?
21
22 When a new version or revision of the SPIR-V specification is published,
23 the SPIR-V Working Group will push new commits onto master, updating
24 the files under [include](include).
25
26 The SPIR-V XML registry file is updated by Khronos whenever a new enum range is allocated.
27
28 Pull requests can be made to 
29 - request allocation of new enum ranges in the XML registry file
30 - reserve specific tokens in the JSON grammar
31
32 ## How to install the headers
33
34 ```
35 mkdir build
36 cd build
37 cmake ..
38 # Linux
39 cmake --build . --target install-headers
40 # Windows
41 cmake --build . --config Debug --target install-headers
42 ```
43
44 Then, for example, you will have `/usr/local/include/spirv/unified1/spirv.h`
45
46 If you want to install them somewhere else, then use
47 `-DCMAKE_INSTALL_PREFIX=/other/path` on the first `cmake` command.
48
49 ## Using the headers without installing
50
51 A CMake-based project can use the headers without installing, as follows:
52
53 1. Add an `add_subdirectory` directive to include this source tree.
54 2. Use `${SPIRV-Headers_SOURCE_DIR}/include}` in a `target_include_directories`
55    directive.
56 3. In your C or C++ source code use `#include` directives that explicitly mention
57    the `spirv` path component.
58 ```
59 #include "spirv/unified1/GLSL.std.450.h"
60 #include "spirv/unified1/OpenCL.std.h"
61 #include "spirv/unified1/spirv.hpp"
62 ```
63
64 See also the [example](example/) subdirectory.  But since that example is
65 *inside* this repostory, it doesn't use and `add_subdirectory` directive.
66
67 ## Generating the headers from the JSON grammar
68
69 This will generally be done by Khronos, for a change to the JSON grammar.
70 However, the project for the tool to do this is included in this repository,
71 and can be used to test a PR, or even to include the results in the PR.
72 This is not required though.
73
74 The header-generation project is under the `tools/buildHeaders` directory.
75 Use CMake to build the project, in a `build` subdirectory (under `tools/buildHeaders`).
76 There is then a bash script at `bin/makeHeaders` that shows how to use the built
77 header-generator binary to generate the headers from the JSON grammar.
78 (Execute `bin/makeHeaders` from the `tools/buildHeaders` directory.)
79
80 Notes:
81 - this generator is used in a broader context within Khronos to generate the specification,
82   and that influences the languages used, for legacy reasons
83 - the C++ structures built may similarly include more than strictly necessary, for the same reason
84
85 ## FAQ
86
87 * *How are different versions published?*
88
89   The multiple versions of the headers have been simplified into a
90   single `unified1` view. The JSON grammar has a "version" field saying
91   what version things first showed up in.
92
93 * *How do you handle the evolution of extended instruction sets?*
94
95   Extended instruction sets evolve asynchronously from the core spec.
96   Right now there is only a single version of both the GLSL and OpenCL
97   headers.  So we don't yet have a problematic example to resolve.
98
99 ## License
100 <a name="license"></a>
101 ```
102 Copyright (c) 2015-2018 The Khronos Group Inc.
103
104 Permission is hereby granted, free of charge, to any person obtaining a
105 copy of this software and/or associated documentation files (the
106 "Materials"), to deal in the Materials without restriction, including
107 without limitation the rights to use, copy, modify, merge, publish,
108 distribute, sublicense, and/or sell copies of the Materials, and to
109 permit persons to whom the Materials are furnished to do so, subject to
110 the following conditions:
111
112 The above copyright notice and this permission notice shall be included
113 in all copies or substantial portions of the Materials.
114
115 MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
116 KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
117 SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
118    https://www.khronos.org/registry/
119
120 THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
121 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
122 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
123 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
124 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
125 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
126 MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
127 ```