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

..03-May-2022-

android_test/H11-Nov-2021-8724

build_overrides/H11-Nov-2021-4134

cmake/H03-May-2022-477426

examples/online-compile/H03-May-2022-172109

glslc/H03-May-2022-11,5268,035

kokoro/H11-Nov-2021-1,483887

libshaderc/H03-May-2022-6,2154,431

libshaderc_util/H03-May-2022-6,0454,061

third_party/H03-May-2022-92,32486,294

utils/H11-Nov-2021-675410

.clang-formatH A D11-Nov-202179 65

.gitignoreH A D11-Nov-2021301 2019

AUTHORSH A D11-Nov-2021310 107

Android.mkH A D11-Nov-20212.5 KiB7748

BUILD.gnH A D11-Nov-20213.2 KiB10287

CHANGESH A D11-Nov-202111.6 KiB289261

CONTRIBUTING.mdH A D11-Nov-20211.4 KiB2620

CONTRIBUTORSH A D11-Nov-2021882 2523

DEPSH A D11-Nov-20211.1 KiB3425

DEVELOPMENT.howto.mdH A D11-Nov-20212.5 KiB5339

DockerfileH A D11-Nov-20211.1 KiB5140

LICENSEH A D11-Nov-202111.1 KiB202169

README.mdH A D11-Nov-202110.4 KiB264198

downloads.mdH A D11-Nov-20211.1 KiB1814

license-checker.cfgH A D11-Nov-2021872 3732

README.md

1# Shaderc
2
3A collection of tools, libraries and tests for shader compilation.
4At the moment it includes:
5
6- [`glslc`](glslc), a command line compiler for GLSL/HLSL to SPIR-V, and
7- [`libshaderc`](libshaderc), a library API for accessing `glslc` functionality.
8
9**Note:** The fact that that `libshaderc` is not named `libshaderc_glslc` is a
10quirk of history, and a known inconsistency. Changing it would require a
11significant amount of renaming and breaking of downstream projects, so it is
12being left as is.
13
14`glslc` wraps around core functionality in [glslang][khr-glslang]
15and [SPIRV-Tools][spirv-tools]. `glslc` and its library aims to
16to provide:
17* a command line compiler with GCC- and Clang-like usage, for better
18  integration with build systems
19* an API where functionality can be added without breaking existing clients
20* an API supporting standard concurrency patterns across multiple
21  operating systems
22* increased functionality such as file `#include` support
23
24## Downloads
25
26**Note: These binaries are just the artifacts of the builders and have not
27  undergone any QA, thus they should be considered unsupported.**
28
29<img alt="Linux" src="kokoro/img/linux.png" width="20px" height="20px" hspace="2px"/>[![Linux Build Status](https://storage.googleapis.com/shaderc/badges/build_status_linux_clang_release.svg)](https://storage.googleapis.com/shaderc/badges/build_link_linux_clang_release.html)
30<img alt="MacOS" src="kokoro/img/macos.png" width="20px" height="20px" hspace="2px"/>[![MacOS Build Status](https://storage.googleapis.com/shaderc/badges/build_status_macos_clang_release.svg)](https://storage.googleapis.com/shaderc/badges/build_link_macos_clang_release.html)
31<img alt="Windows" src="kokoro/img/windows.png" width="20px" height="20px" hspace="2px"/>[![Windows Build Status](https://storage.googleapis.com/shaderc/badges/build_status_windows_vs2017_release.svg)](https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2017_release.html)
32
33[More downloads](downloads.md)
34
35## Status
36
37Shaderc has maintained backward compatibility for quite some time, and we
38don't anticipate any breaking changes.
39Ongoing enhancements are described in the [CHANGES](CHANGES) file.
40
41Shaderc has been shipping in the
42[Android NDK](https://developer.android.com/ndk/index.html) since version r12b.
43(The NDK build uses sources from https://android.googlesource.com/platform/external/shaderc/.
44Those repos are downstream from GitHub.)
45We currently require r18b.
46
47For licensing terms, please see the [`LICENSE`](LICENSE) file.  If interested in
48contributing to this project, please see [`CONTRIBUTING.md`](CONTRIBUTING.md).
49
50This is not an official Google product (experimental or otherwise), it is just
51code that happens to be owned by Google.  That may change if Shaderc gains
52contributions from others.  See the [`CONTRIBUTING.md`](CONTRIBUTING.md) file
53for more information. See also the [`AUTHORS`](AUTHORS) and
54[`CONTRIBUTORS`](CONTRIBUTORS) files.
55
56## File organization
57
58- `android_test/` : a small Android application to verify compilation
59- `cmake/`: CMake utility functions and configuration for Shaderc
60- `examples/`: Example programs
61- `glslc/`: an executable to compile GLSL to SPIR-V
62- `libshaderc/`: a library for compiling shader strings into SPIR-V
63- `libshaderc_util/`: a utility library used by multiple shaderc components
64- `third_party/`: third party open source packages; see below
65- `utils/`: utility scripts for Shaderc
66
67Shaderc depends on glslang, the Khronos reference compiler for GLSL.
68
69Shaderc depends on [SPIRV-Tools][spirv-tools] for assembling, disassembling,
70and transforming SPIR-V binaries.
71
72Shaderc depends on the [Google Test](https://github.com/google/googletest)
73testing framework.
74
75In the following sections, `$SOURCE_DIR` is the directory you intend to clone
76Shaderc into.
77
78## Getting and building Shaderc
79
80**If you only want prebuilt executables or libraries, see the
81[Downloads](#downloads) section.**
82
83The rest of this section describes how to build Shaderc from sources.
84
85Note: Shaderc assumes Glslang supports HLSL compilation.  The instructions
86below assume you're building Glslang from sources, and in a subtree
87of `shaderc/third_party`.  In that scenario, Glslang's HLSL support
88is automatically enabled.  Shaderc also can be built using a Glslang
89from outside the `shaderc/third_party` tree.  In that case you must
90ensure that that external Glslang is built with HLSL functionality.
91See Glslang's `ENABLE_HLSL` CMake setting.)
92
931) Check out the source code:
94
95```sh
96git clone https://github.com/google/shaderc $SOURCE_DIR
97cd $SOURCE_DIR
98./utils/git-sync-deps
99cd $SOURCE_DIR/
100```
101
102**Note:** The [known-good](https://github.com/google/shaderc/tree/known-good)
103branch of the repository contains a
104[known_good.json](https://github.com/google/shaderc/blob/known-good/known_good.json)
105file describing a set of repo URLs and specific commits that have been
106tested together.  This information is updated periodically, and typically
107matches the latest update of these sources in the development branch
108of the Android NDK.
109The `known-good` branch also contains a
110[update_shaderc.py](https://github.com/google/shaderc/blob/known-good/update_shaderc_sources.py)
111script that will read the JSON file and checkout those specific commits for you.
112
1132) Ensure you have the requisite tools -- see the tools subsection below.
114
1153) Decide where to place the build output. In the following steps, we'll call it
116   `$BUILD_DIR`. Any new directory should work. We recommend building outside
117   the source tree, but it is also common to build in a (new) subdirectory of
118   `$SOURCE_DIR`, such as `$SOURCE_DIR/build`.
119
1204a) Build (and test) with Ninja on Linux or Windows:
121
122```sh
123cd $BUILD_DIR
124cmake -GNinja -DCMAKE_BUILD_TYPE={Debug|Release|RelWithDebInfo} $SOURCE_DIR
125ninja
126ctest # optional
127```
128
1294b) Or build (and test) with MSVC on Windows:
130
131```sh
132cd $BUILD_DIR
133cmake $SOURCE_DIR
134cmake --build . --config {Release|Debug|MinSizeRel|RelWithDebInfo}
135ctest -C {Release|Debug|MinSizeRel|RelWithDebInfo}
136```
137
1384c) Or build with MinGW on Linux for Windows:
139(Skip building threaded unit tests due to
140[Googletest bug 606](https://github.com/google/googletest/issues/606))
141
142```sh
143cd $BUILD_DIR
144cmake -GNinja -DCMAKE_BUILD_TYPE={Debug|Release|RelWithDebInfo} $SOURCE_DIR \
145   -DCMAKE_TOOLCHAIN_FILE=$SOURCE_DIR/cmake/linux-mingw-toolchain.cmake \
146   -Dgtest_disable_pthreads=ON
147ninja
148```
149
150After a successful build, you should have a `glslc` executable somewhere under
151the `$BUILD_DIR/glslc/` directory, as well as a `libshaderc` library somewhere
152under the `$BUILD_DIR/libshaderc/` directory.
153
154The default behavior on MSVC is to link with the static CRT. If you would like
155to change this behavior `-DSHADERC_ENABLE_SHARED_CRT` may be passed on the
156cmake configure line.
157
158See [the libshaderc README](libshaderc/README.md) for more on using the library
159API in your project.
160
161### Tools you'll need
162
163For building, testing, and profiling Shaderc, the following tools should be
164installed regardless of your OS:
165
166- [CMake](http://www.cmake.org/): for generating compilation targets.
167- [Python 3](http://www.python.org/): for utility scripts and running the test suite.
168
169On Linux, the following tools should be installed:
170
171- [`gcov`](https://gcc.gnu.org/onlinedocs/gcc/Gcov.html): for testing code
172    coverage, provided by the `gcc` package on Ubuntu.
173- [`lcov`](http://ltp.sourceforge.net/coverage/lcov.php): a graphical frontend
174    for `gcov`, provided by the `lcov` package on Ubuntu.
175- [`genhtml`](http://linux.die.net/man/1/genhtml): for creating reports in html
176    format from `lcov` output, provided by the `lcov` package on Ubuntu.
177
178On Linux, if cross compiling to Windows:
179- [`mingw`](http://www.mingw.org): A GCC-based cross compiler targeting Windows
180    so that generated executables use the Microsoft C runtime libraries.
181
182On Windows, the following tools should be installed and available on your path:
183
184- Visual Studio 2015 or later. Previous versions of Visual Studio may work but
185  are untested and unsupported.
186- Git - including the associated tools, Bash, `diff`.
187
188Optionally, the following tools may be installed on any OS:
189
190 - [`asciidoctor`](http://asciidoctor.org/): for generating documentation.
191   - [`pygments.rb`](https://rubygems.org/gems/pygments.rb) required by
192     `asciidoctor` for syntax highlighting.
193
194### Building and running Shaderc using Docker
195
196Please make sure you have the Docker engine
197[installed](https://docs.docker.com/engine/installation/) on your machine.
198
199To create a Docker image containing Shaderc command line tools, issue the
200following command in `${SOURCE_DIR}`: `docker build -t <IMAGE-NAME> .`.
201The created image will have all the command line tools installed at
202`/usr/local` internally, and a data volume mounted at `/code`.
203
204Assume `<IMAGE-NAME>` is `shaderc/shaderc` from now on.
205
206To invoke a tool from the above created image in a Docker container:
207
208```bash
209docker run shaderc/shaderc glslc --version
210```
211
212Alternatively, you can mount a host directory (e.g., `example`) containing
213the shaders you want to manipulate and run different kinds of tools via
214an interactive shell in the container:
215
216```bash
217$ docker run -i -t -v `pwd`/example:/code shaderc/shaderc
218/code $ ls
219test.vert
220/code $ glslc -c -o - test.vert | spirv-dis
221```
222
223## Bug tracking
224
225We track bugs using GitHub -- click on the "Issues" button on
226[the project's GitHub page](https://github.com/google/shaderc).
227
228## Test coverage
229
230On Linux, you can obtain test coverage as follows:
231
232```sh
233cd $BUILD_DIR
234cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DENABLE_CODE_COVERAGE=ON $SOURCE_DIR
235ninja
236ninja report-coverage
237```
238
239Then the coverage report can be found under the `$BUILD_DIR/coverage-report`
240directory.
241
242## Bindings
243
244Bindings are maintained by third parties, may contain content
245offered under a different license, and may reference or contain
246older versions of Shaderc and its dependencies.
247
248* **Python:** [pyshaderc][pyshaderc]
249* **Rust:** [shaderc-rs][shaderc-rs]
250* **Go:** [gshaderc][gshaderc]
251* **.NET:** [shaderc.net][shadercdotnet]
252* **Common Lisp:** [shadercl][shaderccommonlisp]
253
254[khr-glslang]: https://github.com/KhronosGroup/glslang
255[spirv-tools]: https://github.com/KhronosGroup/SPIRV-Tools
256[spirv-cross]: https://github.com/KhronosGroup/SPIRV-Cross
257[pyshaderc]: https://github.com/realitix/pyshaderc
258[shaderc-rs]: https://github.com/google/shaderc-rs
259[appveyor]: https://ci.appveyor.com/project/dneto0/shaderc
260[dawn]: https://dawn.googlesource.com/dawn
261[gshaderc]: https://github.com/celer/gshaderc
262[shadercdotnet]: https://github.com/jpbruyere/shaderc.net
263[shaderccommonlisp]: https://github.com/JolifantoBambla/shadercl
264