A collection of tools, libraries and tests for shader compilation.
C++ Python C CMake Shell Batchfile Other
Clone or download
ProgramMax and dneto0 Add virtual dtor to classes with virtual functions
IncluderInterface has virtual functions but does not have a virtual
destructor. This class is derived from by FileIncluder w hich overrides
those functions.

Because there is an interface in use here, it is safe to assume some
container is storing IncluderInterface*. If the container instead held
FileIncluder* then the virtual functions wouldn't be needed.

This causes a problem since FileIncluder has member variables. The
destructor of FileIncluder knows to also destruct those member variables
(including deallocating their dynamically allocated memory).

But when IncluderInterface's destructor is called, it is not virtual and
will not call FileIncluder's destructor. So these member variables are
never destroyed and their dynamically allocated memory will be leaked.

In this case, FileIncluder stores a std::unordered_set<std::string>
which will be leaked.

This patch adds a virtual destructor to IncluderInterface to make sure
FileIncluder's destructor is called and this memory isn't leaked.

Use =default and don't redeclare IncluderInterface's dtor
Latest commit 30af9f9 Jun 13, 2018
Failed to load latest commit information.
android_test Fix add_copyright.py and add license to android_test/test.cpp. Apr 29, 2016
cmake Avoid -fPIC for MinGW builds Oct 24, 2017
examples Fix shaderc_compile_to_spv examples in shaderc.h Mar 7, 2017
glslc Add virtual dtor to classes with virtual functions Jun 18, 2018
kokoro [kokoro] Update Windows bots. (#468) Jun 13, 2018
libshaderc Update to Glslang generator version 7 Jun 11, 2018
libshaderc_util Force binary mode when writing a binary to stdout May 11, 2018
third_party Adjust configuration to link SPIRV-Tools into Glslang May 11, 2018
utils copyright check: Skip auto-generated CMakeFiles Feb 27, 2018
.appveyor.yml Fix setting of debug DLL name for AppVeyor Mar 1, 2018
.gitignore Allow SPIRV-Headers to be checked out at third_party/ Oct 4, 2017
.travis.yml Travis: download and install pip May 11, 2018
AUTHORS Initial commit of shaderc. Aug 6, 2015
Android.mk Add the SPIRV-Tools-opt library into Android.mk. Sep 21, 2016
CHANGES Support -fhlsl_functionality1 Apr 17, 2018
CMakeLists.txt Introduce new option to skip installation Jul 4, 2017
CONTRIBUTING.md Use monospace font and add links where appropriate. Aug 14, 2015
CONTRIBUTORS Add Adam Chainz (adam@adamj.eu) into CONTRIBUTORS. Jun 20, 2016
DEVELOPMENT.howto.md Mention that we build & test on Mac OS X. Mar 23, 2016
Dockerfile Update Dockerfile to pull SPIRV-Headers before building. Jul 18, 2016
LICENSE Initial commit of shaderc. Aug 6, 2015
README.md Add build result badges to README. (#439) Mar 14, 2018



Linux and Mac Build Status Windows Build status Coverage Status

Latest Build Status by Google:

LinuxLinux Build Status MacOSMacOS Build Status WindowsWindows Build Status

A collection of tools, libraries and tests for shader compilation. At the moment it includes:

  • glslc, a command line compiler for GLSL/HLSL to SPIR-V, and
  • libshaderc, a library API for doing the same.

Shaderc wraps around core functionality in glslang and SPIRV-Tools. Shaderc aims to to provide:

  • a command line compiler with GCC- and Clang-like usage, for better integration with build systems
  • an API where functionality can be added without breaking existing clients
  • an API supporting standard concurrency patterns across multiple operating systems
  • increased functionality such as file #include support


Shaderc has maintained backward compatibility for quite some time, and we don't anticipate any breaking changes. Ongoing enhancements are described in the CHANGES file.

Shaderc has been shipping in the Android NDK since version r12b. (The NDK build uses sources from https://android.googlesource.com/platform/external/shaderc/. Those repos are downstream from GitHub.)

For licensing terms, please see the LICENSE file. If interested in contributing to this project, please see CONTRIBUTING.md.

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google. That may change if Shaderc gains contributions from others. See the CONTRIBUTING.md file for more information. See also the AUTHORS and CONTRIBUTORS files.

File organization

  • android_test/ : a small Android application to verify compilation
  • cmake/: CMake utility functions and configuration for Shaderc
  • examples/: Example programs
  • glslc/: an executable to compile GLSL to SPIR-V
  • libshaderc/: a library for compiling shader strings into SPIR-V
  • libshaderc_util/: a utility library used by multiple shaderc components
  • third_party/: third party open source packages; see below
  • utils/: utility scripts for Shaderc

Shaderc depends on glslang, the Khronos reference compiler for GLSL. Sometimes a change updates both Shaderc and glslang. In that case the glslang change will appear in google/glslang before it appears upstream in KhronosGroup/glslang We intend to upstream all changes to glslang. We maintain the separate copy only to stage those changes for review, and to provide something for Shaderc to build against in the meantime. Please see DEVELOPMENT.howto.md for more details.

Shaderc depends on SPIRV-Tools for assembling, disassembling, and transforming SPIR-V binaries.

Shaderc depends on the Google Test testing framework.

In the following sections, $SOURCE_DIR is the directory you intend to clone Shaderc into.

Getting and building Shaderc

Experimental: On Windows, instead of building from source, you can get the artifacts built by Appveyor for the top of the tree of the master branch under the "Artifacts" tab of a certain job.

  1. Check out the source code:
git clone https://github.com/google/shaderc $SOURCE_DIR
cd $SOURCE_DIR/third_party
git clone https://github.com/google/googletest.git
git clone https://github.com/google/glslang.git
git clone https://github.com/KhronosGroup/SPIRV-Tools.git spirv-tools
git clone https://github.com/KhronosGroup/SPIRV-Headers.git spirv-headers

Note: The known-good branch of the repository contains a known_good.json file describing a set of repo URLs and specific commits that have been tested together. This information is updated periodically, and typically matches the latest update of these sources in the development branch of the Android NDK. The known-good branch also contains a update_shaderc.py script that will read the JSON file and checkout those specific commits for you.

  1. Ensure you have the requisite tools -- see the tools subsection below.

  2. Decide where to place the build output. In the following steps, we'll call it $BUILD_DIR. Any new directory should work. We recommend building outside the source tree, but it is also common to build in a (new) subdirectory of $SOURCE_DIR, such as $SOURCE_DIR/build.

4a) Build (and test) with Ninja on Linux or Windows:

cmake -GNinja -DCMAKE_BUILD_TYPE={Debug|Release|RelWithDebInfo} $SOURCE_DIR
ctest # optional

4b) Or build (and test) with MSVC on Windows:

cmake --build . --config {Release|Debug|MinSizeRel|RelWithDebInfo}
ctest -C {Release|Debug|MinSizeRel|RelWithDebInfo}

4c) Or build with MinGW on Linux for Windows: (Skip building threaded unit tests due to Googletest bug 606)

cmake -GNinja -DCMAKE_BUILD_TYPE={Debug|Release|RelWithDebInfo} $SOURCE_DIR \
   -DCMAKE_TOOLCHAIN_FILE=$SOURCE_DIR/cmake/linux-mingw-toolchain.cmake \

After a successful build, you should have a glslc executable somewhere under the $BUILD_DIR/glslc/ directory, as well as a libshaderc library somewhere under the $BUILD_DIR/libshaderc/ directory.

The default behavior on MSVC is to link with the static CRT. If you would like to change this behavior -DSHADERC_ENABLE_SHARED_CRT may be passed on the cmake configure line.

See the libshaderc README for more on using the library API in your project.

Tools you'll need

For building, testing, and profiling Shaderc, the following tools should be installed regardless of your OS:

  • CMake: for generating compilation targets.
  • Python: for utility scripts and running the test suite.

On Linux, the following tools should be installed:

  • gcov: for testing code coverage, provided by the gcc package on Ubuntu.
  • lcov: a graphical frontend for gcov, provided by the lcov package on Ubuntu.
  • genhtml: for creating reports in html format from lcov output, provided by the lcov package on Ubuntu.

On Linux, if cross compiling to Windows:

  • mingw: A GCC-based cross compiler targeting Windows so that generated executables use the Micrsoft C runtime libraries.

On Windows, the following tools should be installed and available on your path:

  • Visual Studio 2013 Update 4 or later. Previous versions of Visual Studio will likely work but are untested.
  • Git - including the associated tools, Bash, diff.

Optionally, the following tools may be installed on any OS:

Building and running Shaderc using Docker

Please make sure you have the Docker engine installed on your machine.

To create a Docker image containing Shaderc command line tools, issue the following command in ${SOURCE_DIR}: docker build -t <IMAGE-NAME> .. The created image will have all the command line tools installed at /usr/local internally, and a data volume mounted at /code.

Assume <IMAGE-NAME> is shaderc/shaderc from now on.

To invoke a tool from the above created image in a Docker container:

docker run shaderc/shaderc glslc --version

Alternatively, you can mount a host directory (e.g., example) containing the shaders you want to manipulate and run different kinds of tools via an interactive shell in the container:

$ docker run -i -t -v `pwd`/example:/code shaderc/shaderc
/code $ ls
/code $ glslc -c -o - test.vert | spirv-dis

Bug tracking

We track bugs using GitHub -- click on the "Issues" button on the project's GitHub page.

Test coverage

On Linux, you can obtain test coverage as follows:

ninja report-coverage

Then the coverage report can be found under the $BUILD_DIR/coverage-report directory.


Bindings are maintained by third parties, may contain content offered under a different license, and may reference or contain older versions of Shaderc and its dependencies.