Import Tint changes from Dawn

Contains a manual fix for CMakeList.txt changes.

Changes: - b6903295a826f5378b0445c36da7859373645e45 tint/resolver: Support error cases with const-eval builti... by Ben Clayton <bclayton@google.com>
  - 6fcc4f3a54eff1f2b134d0ec4fa5c69db83adb80 tint: const eval of reverseBits by Antonio Maiorano <amaiorano@google.com>
  - a4314fabb471f491688b7275327cd31481d3bad7 Minor build/include fixes for google3 roll. by Loko Kung <lokokung@google.com>
  - 16b4cf87d0890a0e9bd3bd41df828b8a029a4a26 Template cmake for generated files. by dan sinclair <dsinclair@chromium.org>
  - 6590cc4fd929c4ed6b3043c1c6bf769de20c2a7b Add missing benchmark test. by dan sinclair <dsinclair@chromium.org>
  - 8fa6c25b7868d2445413e20b3deaf117a02446ad tint: Add Initialize() / Shutdown() public APIs by Ben Clayton <bclayton@google.com>
  - 02f04d914d21b30fdda5d69dea08076043be36de tint/transform: Polyfill bit-shift with RHS modulo by Ben Clayton <bclayton@google.com>
  - 91e27f25f984e2156eb535421f1650c8a459fb70 Add const-eval for `floor`. by dan sinclair <dsinclair@chromium.org>
  - 11cecc1e4ffb1c9604ab3d7407dc625918636354 Revert "Add CMake build option to generate intrinsic file... by dan sinclair <dsinclair@chromium.org>
  - abd6a7d9d4a40c2b109cca4cc1ccd420409333bc Add const-eval for `ceil` by dan sinclair <dsinclair@chromium.org>
  - 465df13196c674ebe60eaf30efc6220c88e30457 Revert "This CL updates the cmake files to use go run dir... by Dan Sinclair <dsinclair@chromium.org>
  - 9cbc7e1e54b5b6385c4529cdc30f9398514aadf1 Implement const-eval for `acos` by dan sinclair <dsinclair@chromium.org>
  - b3518d8b4dd9be70af0bf166bac7f5921c2725e0 Implement const eval of `abs` by dan sinclair <dsinclair@chromium.org>
  - 5ae03c266a590cd119dd16e2eaaaef60b943df12 Revert "Scaffolding for generation of intrinsics files." by Dan Sinclair <dsinclair@chromium.org>
  - 11f0c52bfb4bb22293f7ba867dbd33fd4f89d139 tint: const eval of extractBits by Antonio Maiorano <amaiorano@google.com>
  - 58eca19f33a7068c2571a430746922faa03a0871 Add const-eval for `all`. by dan sinclair <dsinclair@chromium.org>
  - aa4b64f4c8d1456a70e2f66f305457d255b952d3 tint/utils: Optimise HashmapBase::Scan() by Ben Clayton <bclayton@google.com>
  - c6b381495db0bdabb8fd9eb1f33e0097099bbd7e tint/transform: Refactor transforms by Ben Clayton <bclayton@google.com>
  - 336f3536e5c6b7a0b63dd7c92c58770d5a0812b5 tint: const eval of insertBits by Antonio Maiorano <amaiorano@google.com>
  - e372511e1ba20f24fde0e1999fd318daeea13581 tint/utils: Rework Hashmap / Hashset by Ben Clayton <bclayton@google.com>
  - 9535f7220913acd92d59c76009cb31b9410b1e21 tint/validator: Hint 'var' instead of 'const' by Ben Clayton <bclayton@google.com>
  - fd9c3fe4bcedb2f1aed628c27fe6d38a768f2a89 tint/uniforimty: Remove short-circuit special-case by James Price <jrprice@google.com>
  - c81f9dce07e5ea41e8aa1f65bc619b6ed669403b tint: Implement const-eval of quantizeToF16 by Ben Clayton <bclayton@google.com>
  - 749abeaafb609a9d1b0be758489cc4d4bc137ba8 Revert "Add GN build option to build using generated file... by Dan Sinclair <dsinclair@chromium.org>
  - a950d4539ed6e6846616804b2b986f79460bc484 This CL updates the cmake files to use go run directly. by dan sinclair <dsinclair@chromium.org>
  - bdd5bbe0c5d3b0f0a1800d7ec0cf814376ec3dde tint/transform/utils: HoistToDeclBefore polish by Ben Clayton <bclayton@google.com>
  - 2d63e321fd6c0342ba405204df0f978c3b3865be tint: Add callback overloads to CloneContext::Insert* by Ben Clayton <bclayton@google.com>
  - b5c213b9951681beca81de2b7fda3c448df850f0 tint/resolver: Fix failures with no error by Ben Clayton <bclayton@google.com>
  - 6ab5d3c1519e3b8d76598a20a5fdc3bb84d35fd2 Tint/transform: make AddBlockAttribute always do wrapping... by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - 2bea9055f429c3b7708b2fa33f4539c1ce98c6ad tint: Implement runtime quantizeToF16() by Ben Clayton <bclayton@google.com>
  - 35da05462438b316889e88fe0f81a8e58500ee7a tint/cmake: Fix test source paths by James Price <jrprice@google.com>
  - ed0649dec4f1324320d4f678819eaa48e57a5aed [IR] Fix setting of if merge target by dan sinclair <dsinclair@chromium.org>
  - 9261261da87ee8bfc9564c5addec3d59cf4308e0 [IR] Add ability to dump IR graph to dot by dan sinclair <dsinclair@chromium.org>
  - 1c755b68e6ff93fa734c43e5b45e4cd528c92c11 [IR] Add support for `for` statements by dan sinclair <dsinclair@chromium.org>
  - 0dce067e286e3d72b929af1f06e2cc332aee2dc5 [IR] Add support for `while` statements. by dan sinclair <dsinclair@chromium.org>
  - 7cd8db11558e427820d646219a69787b99e86431 Add GN build option to build using generated files. by dan sinclair <dsinclair@chromium.org>
  - 50c29f6d38b3d471bc4036faae11020530538d86 [IR] Add support for `fallthrough`. by dan sinclair <dsinclair@chromium.org>
  - c22b8b9dc8c058fef45c72a3c2cdd70d90fc911d Add CMake build option to generate intrinsic files. by dan sinclair <dsinclair@chromium.org>
  - c02feff258e22a54de14f8afae851d0c3665e6f5 tint/cmd: Add `--rename-all` flag by Ben Clayton <bclayton@google.com>
  - d336733c8338ae5bf3f4eadf9bcf8c286cd20fba [IR] Add switch control flow node. by dan sinclair <dsinclair@chromium.org>
  - b9ed75cf2fe5ab8d759da17a9cfe0befb286a1a1 [IR] Track inbound branches to flow nodes. by dan sinclair <dsinclair@chromium.org>
  - 6c5db2afa69756f8f07efd942c88ad5b173fc738 Scaffolding for generation of intrinsics files. by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: b6903295a826f5378b0445c36da7859373645e45
Change-Id: Ie32c6158b8dab82f8097785131a34c44b9892986
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/108921
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@chromium.org>
171 files changed
tree: fb5466013d5522e442ba0b5a758acea5ba5347ce
  1. .vscode/
  2. build_overrides/
  3. docs/
  4. include/
  5. infra/
  6. kokoro/
  7. src/
  8. third_party/
  9. tools/
  10. .clang-format
  11. .gitignore
  12. .gn
  13. AUTHORS
  14. BUILD.gn
  15. CMakeLists.txt
  16. CMakeSettings.json
  17. CODE_OF_CONDUCT.md
  18. CPPLINT.cfg
  19. DEPS
  20. Doxyfile
  21. LICENSE
  22. OWNERS
  23. PRESUBMIT.py
  24. README.md
  25. standalone.gclient
  26. tint_overrides_with_defaults.gni
README.md

Tint


Note: This repo is read-only, minimized mirror of the Dawn repo.

Tint changes should be made in the Dawn repo.


Tint is a compiler for the WebGPU Shader Language (WGSL).

This is not an officially supported Google product.

Requirements

  • Git
  • CMake (3.10.2 or later)
  • Ninja (or other build tool)
  • Python, for fetching dependencies
  • depot_tools in your path

Build options

  • TINT_BUILD_SPV_READER : enable the SPIR-V input reader (off by default)
  • TINT_BUILD_WGSL_READER : enable the WGSL input reader (on by default)
  • TINT_BUILD_SPV_WRITER : enable the SPIR-V output writer (on by default)
  • TINT_BUILD_WGSL_WRITER : enable the WGSL output writer (on by default)
  • TINT_BUILD_FUZZERS : enable building fuzzzers (off by default)

Building

Tint uses Chromium dependency management so you need to install depot_tools and add it to your PATH.

Getting source & dependencies

# Clone the repo as "tint"
git clone https://dawn.googlesource.com/tint tint
cd tint

# Bootstrap the gclient configuration
cp standalone.gclient .gclient

# Fetch external dependencies and toolchains with gclient
gclient sync

Compiling using CMake + Ninja

mkdir -p out/Debug
cd out/Debug
cmake -GNinja ../..
ninja # or autoninja

Compiling using CMake + make

mkdir -p out/Debug
cd out/Debug
cmake ../..
make # -j N for N-way parallel build

Compiling using gn + ninja

mkdir -p out/Debug
gn gen out/Debug
autoninja -C out/Debug

Fuzzers on MacOS

If you are attempting fuzz, using TINT_BUILD_FUZZERS=ON, the version of llvm in the XCode SDK does not have the needed libfuzzer functionality included.

The build error that you will see from using the XCode SDK will look something like this:

ld: file not found:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.fuzzer_osx.a

The solution to this problem is to use a full version llvm, like what you would get via homebrew, brew install llvm, and use something like CC=<path to full clang> cmake .. to setup a build using that toolchain.

Checking [chromium-style] issues in CMake builds

The gn based work flow uses the Chromium toolchain for building in anticipation of integration of Tint into Chromium based projects. This toolchain has additional plugins for checking for style issues, which are marked with [chromium-style] in log messages. This means that this toolchain is more strict then the default clang toolchain.

In the future we will have a CQ that will build this work flow and flag issues automatically. Until that is in place, to avoid causing breakages you can run the [chromium-style] checks using the CMake based work flows. This requires setting CC to the version of clang checked out by gclient sync and setting the TINT_CHECK_CHROMIUM_STYLE to ON.

mkdir -p out/style
cd out/style
cmake ../..
CC=../../third_party/llvm-build/Release+Asserts/bin/clang cmake -DTINT_CHECK_CHROMIUM_STYLE=ON ../../ # add -GNinja for ninja builds

Issues

Please file any issues or feature requests at https://bugs.chromium.org/p/tint/issues/entry

Contributing

Please see the contributing guide in the Dawn repo.