• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

cmake/23-Nov-2023-53

example/23-Nov-2023-9125

include/spirv/23-Nov-2023-70,43367,936

tools/buildHeaders/23-Nov-2023-9,1876,436

.gitattributesD23-Nov-202372 87

.gitignoreD23-Nov-202320 43

Android.bpD23-Nov-20231.2 KiB3532

CMakeLists.txtD23-Nov-20233.8 KiB11699

CODE_OF_CONDUCT.mdD23-Nov-2023280 21

LICENSED23-Nov-20231.3 KiB2621

METADATAD23-Nov-202339 43

OWNERSD23-Nov-202338 32

README.mdD23-Nov-20235.1 KiB133100

README.md

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