Merge remote-tracking branch 'aosp/upstream-master' into update-shaderc

Includes:
a84571c Add support for missing CallableNV shader stage
e2ddeea [ci] Remove Travis and Appveyor CI
dd41537 Set the CMake C++ standard to C++11
38fbaed Specify NV_EXTENSIONS for Android build
0165db5 Add BUILD.gn rules
9340ae5 Re-order glslc help (almost) alphabetically and add -O, -Os, -O0
5cd480f Add new Glslang files to Android.mk
a8dcbfa [appveyor] Use the correct filename for shared library
10aee4a [appveyor] Disable testing on VS2013
3104e38 [travis] Update Android NDK toolchain
8973958 [kokoro] Skip building SPIRV-tools tests on VS 2013
e7a6a26 [kokoro] Checkout effcee and re2 repos
7aef860 Update CHANGES.  (E.g. Added NV Turing extensions)
b430877 Add-support-for-SPV_NVX_raytracing
e8ffa06 Add-support-for-SPV_NV_mesh_shader
30af9f9 Add virtual dtor to classes with virtual functions
a2c044c [kokoro] Update Windows bots. (#468)
f7efa14 Update to Glslang generator version 7
be8e087 Travis: download and install pip
4f36a64 Force binary mode when writing a binary to stdout
87a8420 Adjust configuration to link SPIRV-Tools into Glslang
5fd1b25 Support -fhlsl_functionality1
8dec681 Also install shaderc_shared.dll on windows.
2a0f3a3 Use standard SPIRV-Tools transformation recipes
583fb13 Locate clang for Linux buildbots. (#446)
c993158 Support setting target environment version, e.g. Vulkan 1.1
45e1621 Re-enable the Windows continuous Debug builds. (#444)
fc15f0a Add build result badges to README. (#439)
371d6ef Glslang generator version 6
0d23433 Glslang generator version 5
b6d4dcb Update glslc README for -fauto-map-locations
cce7bbc Add glslc tests for -fauto-map-locations
13c6d97 Fix setting of debug DLL name for AppVeyor
461cc14 Adding kokoro build configurations. (#429)
e55a246 AppVeyor packaging: debug DLL name no longer has extra "d"
dbb0f14 Start v2018.0-dev
7a23a01 Finalize v2017.2
10530a0 copyright check: Skip auto-generated CMakeFiles
1628033 Update CHANGES for -fauto-map-locations
afb2658 Glslang now requires bindings on resources
d1f763c Add -fauto-map-locations option
563bc6e Add a virtual destructor, otherwise Clang 6.0complains about delete being called on an abstract class.
c7b5df4 Skip Debug builds for VS 2013 and VS 2015
66aac8c Glslang updated its generator version number to 4
5d4b3f4 Android.mk: add glslang/MachineIndependent/attribute.cpp
773ec22 Make tests resilient to better SPIR-V optimizations
22aee5d Travis CI: install pip and set clone depth to 1
ad86c6c Adapt to Glslang codegen version update
98ab88b glslc tests: Relax version word check
c607253 Avoid -fPIC for MinGW builds
1927f30 Allow override of SPVTOOLS_LOCAL_PATH
bcadbc1 Move spirv-tools build from third_party/Android.mk
3fde660 Update CHANGES
c815335 Adapt to Glslang generator version number change
259ca18 Travis CI: use make to build
16f8253 Add HLSL legalization passes to compiler.cc
e089609 Add SPIRV-Tools optimizer files for linker
84c9dd9 Added more opt passes to PassId enum
b58a21a Fix typos in README.md
5c4fd69 Allow SPIRV-Headers to be checked out at third_party/
c677f26 Include SPIRV-Tools before glslang
8aa64c6 Appveyor: stop downloading pip
c8ba3e4 Check _WIN32 instead of WIN32 for building shared library
00c9fe4 Appveyor: Stop deploying to BinTray
97e0e13 Appveyor: deploy to BinTray instead of GitHub Release page
0b99bfa Serialize inclusions by the CountingIncluder
4cdf49e Fix the build by changing deploy repo
6db3870 Deploy Appveyor build artifacts to GitHub Releases
7ad5b69 SPIRV-Tools added source/validate_bitwise.cpp
4138101 SPIRV-Tools added source/opt/eliminate_dead_functions_pass.cpp
61eb9ff Android: Fix generation of 1.2 grammar tables
c77e1e9 SPIRV-Tools added source/validate_logicals.cpp
eadd549 SPIRV-Tools added source/opt/strength_reduction_pass.cpp
c56b7dc Add shared library variant for libshaderc
777c9ff SPIRV-Tools added validate_arithmetics.cpp
12fb656 Don't build HTML docs by default
1803679 SPIRV-Tools added source/opt/inline_opaque_pass.cpp
280b66d SPIRV-Tools: Add source/opt/pass.cpp
c276932 Android.mk: Add source/id_descriptor.cpp to SPIRV-Tools
7d7725f Add SPIRV-Tools opt/inline_exhaustive_pass.cpp
ab73cf3 Add SPIRV-Tools source/opt/common_uniform_elim_pass.cpp
274d102 Support GLSL 4.6 and ESSL 3.2
9752555 Add source/opt/mem_pass.cpp to SPRIV-Tools
d10af57 Add Appveyor configs for VS 2015, VS 2017
aa8f376 Adapt to Glslang error changes
fb33022 Add recent SPIRV-Tools source file additions
41ce8e6 Fix Glslang Android build
f382c71 Update CHANGES to mention use of GNUInstallDirs
e27569f Introduce new option to skip installation
cd5199f Glslang requires -DENABLE_HLSL
7bd63fb Add block_merge_pass.cpp to SPIRV-Tools
ef03acd Increase default maxDrawBuffers
2f68ce7 Add SPIRV-Tools file source/opt/insert_extract_elim.cpp
c4b491b SPIRV-Tools added source/opt/local_single_store_elim_pass.cpp
62fd200 Avoid unnecessary lambda capture
8f79dd1 Reorganize options in glslc README
63d0f82 Add -fresource-set-binding
bf60221 Add option to set HLSL register descriptor set and binding
44dff89 Add -fhlsl-offsets
6194f07 Render table of contents for glslc manual
aede4fe Fix Glslang test dir path for MSVC build
760c3f5 React to new SPIRV-Tools source files
0dd731a React to removed Glslang .cpp files
1adfc98 Update tests for Glslang global warning changes
6ff1564 Add layout(location = 0) where needed in tests.
b1228ba Adjust copying of Glslang test files, for include test
558dede Shorten arg checking for -f*-binding-base
7df8217 Reject negative numbers when parsing unsigned.
63313f9 Add -fuav-binding-base
cdcc015 Support setting SSBO binding base
357d24b Add glslc options to set binding base for uniforms
735a541 Add shaderc_compile_options_set_binding_base_for_stage
c1729a4 Add libshaderc_util::Compiler::SetAutoBindingBaseForStage
2c7db7c Add shaderc_util::Compiler::Stage
da4f9b0 Add generic names for shader stages
a290067 Add glslc options to set binding base numbers
d8eb937 Add C, C++ API to set binding base for uniforms
b54a418 Add libshaderc_util::SetAutoBindingBase
b7b4892 Add -flimit-file to glslc doc summary
a532710 Document some recent changes, e.g. HLSL offsets
7261ab8 Fix Travis-CI so ctest emits output on failure
3c85d26 Make git ignore android_test/libs
580d540 Support SPIR-V 1.2 in SPIRV-Tools Android build
dcb3036 Avoid mem leaks in counting includer test
44823cb Add util/bit_stream.cpp in Android.mk for SPIRV-Tools
a571eef Trim Appveyor notification list
659b796 Fix test to update glslang
9b3dbd1 Avoid noexcept-type in GCC 7.1 for test code
21e2016 Added compact_ids_pass.cpp to Android.mk
380e143 React to Glslang #version error message for HLSL
ed5e93e Update tests for different Glslang error message
3966711 SPIRV-Tools added flatten decorations pass
6509a8b Update tests for Glslang message changes
32b0c71 Add SPIRV-Tools source file for its MR534
71b9b3b Support non-standard vendor extended instructions
c698442 Add pervasive dependency to extension_enum.inc
97ab4d1 SPIRV-Tools added source/validate_capability.cpp
9a08e4a Added extension enum, mapping autogen to android
fef405c Add util/string_utils.cpp to SPIRV-Tools
9faaa69 Fix include error message when no options object
e29176b Start v2017.2-dev
1b4359c Finalize v2017.1
b541cc5 Update CHANGES with all recent key items
6d49dcf Mention Rust binding in README
7da4872 Describe the known-good branch
864d819 SPIRV-Tools added source/extensions.cpp
5432099 Clarify that bindings are maintained by others
0609612 Add Bindings section in Readme
1a149f6 Fix shaderc_compile_to_spv examples in shaderc.h
cb4f0f6 Describe includer error convention in the struct.
48b5f88 Add comment to explain how to return an error in callback
9c3a4ee Use OpenCL extended instruction set from SPIRV-Headers
5c6247c Add validate_type_unique.cpp to SPIRV-Tools
b4f0c10 Add spirv_validator_options.cpp to SPIRV-Tools
83afd96 Update CHANGES to say NVIDIA extensions enabled
f6d5124 Enable NV_EXTENSIONS for Android build of glslang
849ae99 Install shaderc header files.
7ae44a1 Add -fauto-bind-uniforms to glslc
ea687fd Add C, C++ API option to auto bind uniforms
fc60017 Add libshader_util::Compiler::SetAutoBindUniforms
26c29e4 Test compiler option to auto bind uniforms
6ec47b0 Fix installation of libshaderc_combined.a on Windows.
0de1e58 Add CMake configuration to install shaderc libraries.
4fa3150 SPIRV-Tools added source/validate_decorations.cpp
9f7547d Allow build time to be overidden.
38777c7 Update Travis CI configuration.
dd79e70 Adapt to Glslang Includer interface changes.
0675ac7 Updated CMake configuration for Android Studio. (#296)
607daae Allow trailing whitespace in version lines in CHANGES
c5cfcc5 Adapt to Glslang include message changes
419214b Don't write an output file if compilation fails
138757e shaderc_util::GetOutputStream sends errors to a given stream
54fa1d7 Set the tool to Google Shaderc over Glslang
30e5bc0 Start v2016.3-dev
2fb6a3a Finalize v2016.2
e3f0d2e Add -Werror to Android build
4ff1d25 Add rule for creating SPIRV-Tools generators.inc file
01921d4 Updated maxDrawBuffers to be consistent with Vulkan/GLES3.0 (#283)

Change-Id: Ib5ffc53fb129e8880350bae3fa7a98bf729e89da
Testing: checkbuild.py on Linux; unit tests on Windows
tree: f8b08e3232b927e950b9403c7822e6b3b1a48c9e
  1. .gitignore
  2. AUTHORS
  3. Android.mk
  4. BUILD.gn
  5. CHANGES
  6. CMakeLists.txt
  7. CONTRIBUTING.md
  8. CONTRIBUTORS
  9. DEVELOPMENT.howto.md
  10. Dockerfile
  11. LICENSE
  12. README.md
  13. android_test/
  14. build_overrides/
  15. cmake/
  16. examples/
  17. glslc/
  18. kokoro/
  19. libshaderc/
  20. libshaderc_util/
  21. third_party/
  22. utils/
README.md

Shaderc

Linux Build Status MacOS Build Status Windows 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

Status

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
cd $SOURCE_DIR/

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:

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

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

cd $BUILD_DIR
cmake $SOURCE_DIR
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)

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

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
test.vert
/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:

cd $BUILD_DIR
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DENABLE_CODE_COVERAGE=ON $SOURCE_DIR
ninja
ninja report-coverage

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

Bindings

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.