Import Tint changes from Dawn

Changes:
  - 7e0d9e6843de383e721d2c269d6a64e3537a244b [tint] Handle empty tables in intrinsic table data template by Ben Clayton <bclayton@google.com>
  - 3c54ba593c7811c6ddcf5f61f8610187d210aa16 [tint][wgsl] Move LanguageFeature to a separate target by Ben Clayton <bclayton@google.com>
  - 2e26e7a6f8f48e67d099c3237f53da5708197fc6 [tint][msl][ir] Use ValueToLet IR transform by Ben Clayton <bclayton@google.com>
  - d9ffa54c787dbd790f4896bd522121a5c40b4ef4 [tint][ir] Add ValueToLet transform by Ben Clayton <bclayton@google.com>
  - e6d2cd002804c1543b3ca60a25715d04a4e76c98 [tint][spirv] Add a SPIR-V writer IR fuzzer. by Ben Clayton <bclayton@google.com>
  - fb6a9bcd2ce8771d696ee86ec41753b9ab5600aa [tint][ir] Remove default parameters for Operand() and Re... by Ben Clayton <bclayton@google.com>
  - da8a08aefec265090b9aedbbeaea919b81395904 [tint][ir] Change Instruction::Result() return type by Ben Clayton <bclayton@google.com>
  - 08396a3b9ac5c58fc0e86e3c3b53869228c8d6f9 [tint][ir] Add Builder overloads that take the type as a ... by Ben Clayton <bclayton@google.com>
  - 6a235972b207be3b9e6395d02aff71141562885b [tint][cmake] Pass -Wno-gnu-zero-variadic-macro-arguments by Ben Clayton <bclayton@google.com>
  - 84cd0f83d5f3661bd4d2f10287775e778589c14e [tint][ir] Always emit ir::Let for WGSL lets by Ben Clayton <bclayton@google.com>
  - 7e6e44fbf9d65645056e8759bddcff259884fa11 [tint][wgsl] Migrate IR roundtrip fuzzer to be an IR fuzzer by Ben Clayton <bclayton@google.com>
  - 339941969ddb111159ba1696728fdfe6e01783d4 [tint][fuzz] Add an IR fuzzer framework by Ben Clayton <bclayton@google.com>
  - bfa79963bcdda05644bce8857f13b980f76655b1 [tint][spirv] Add a SPIR-V writer fuzzer from AST by Ben Clayton <bclayton@google.com>
  - 881eff88cf623325bbb891a0c07c1ef0e0a612d2 [tint][spirv] Add validate library by Ben Clayton <bclayton@google.com>
  - 5ee5f187deed9ef125de1e6177d95fdf7beb2967 [ir][msl] Run existing transforms which are required. by dan sinclair <dsinclair@chromium.org>
  - 571cc4420ff93b2ff9ed49ef2c076191563c87df Remove chromium_experimental_read_write_storage_texture f... by Jiawei Shao <jiawei.shao@intel.com>
  - 2a21ac0c3b4f4b18afb69aefbf7a390915b13ef2 [ir][msl] Add support for fragment inputs by dan sinclair <dsinclair@chromium.org>
  - 71da3e8aa054ec1e8d36f65a07b975ad8d02de0f [ir][msl] Add thread and threadgroup position. by dan sinclair <dsinclair@chromium.org>
  - 9ffc1d92cb4b6a599dc8803a9d84f28821c5b27d [ir][msl] Fix const of non-entrypoint pointers by dan sinclair <dsinclair@chromium.org>
  - b4697b7658625f704b18f25f291a7e7557e90537 [ir][msl] Emit some core builtins. by dan sinclair <dsinclair@chromium.org>
  - 050f08c3f5c84ba3721b26a6765e6084ce497f1e Fix TINT_FOREACH_13, _14 and _15 by Jiawei Shao <jiawei.shao@intel.com>
  - 9aa5b553322a54c0ecd3c9eb71bf2d12ad8932b6 [tint] Fix Bazel config_setting_group definition by André Cruz <andre@cabine.org>
  - aa5190b63b384a21e1eab9769a7069fe850a72fc [ir] Lower IR before dumping. by dan sinclair <dsinclair@chromium.org>
  - 9cad74f4170393ee91dead059cd57b86bce70cb4 [ir][msl] Emit swizzle, load/store vector element instruc... by dan sinclair <dsinclair@chromium.org>
  - af2c7345c2db8227dd83558eeb0095eb5af20db8 [ir] Rename InstructionResult::Source. by dan sinclair <dsinclair@chromium.org>
  - 2e2bf672c68214f87aec7b8dfdefef943d67c23a [ir][msl] Emit switch instructions by dan sinclair <dsinclair@chromium.org>
  - 3b4bf191b3afa8902d3a39c21e1bca76a8246752 [ir][msl] Emit loops by dan sinclair <dsinclair@chromium.org>
  - b4ec73fd56384fd586caec2ae80af3b0fa144776 [ir][msl] Emit unary instructions by dan sinclair <dsinclair@chromium.org>
  - 99204da719f0f1f76b79afb306ac6d5fa81269e2 [ir][msl] Emit function parameters by dan sinclair <dsinclair@chromium.org>
  - a5460d0c97c7c07a49e65fdbfeed1af6ff41f7e4 [tint][utils] Fix diagnostic initializer_list ctor by Ben Clayton <bclayton@google.com>
  - 624e8dd3ae8c510f85929e5e17db8591e19e2fb6 Add user call tests by dan sinclair <dsinclair@chromium.org>
  - 5c69ff44659e270f174e132064ac0a2eaaab5fb0 [tint] Add tint_build_is_<OS> defines and build flags by Ben Clayton <bclayton@google.com>
  - 1cc545189477077687e73b77aed757ad341bef8a [ir][msl] Emit ir::UserCall by dan sinclair <dsinclair@chromium.org>
  - 3505ed4c5fc1eb6532562b14a77627249839843e Add struct index accessor tests by dan sinclair <dsinclair@chromium.org>
  - 48318cd9d31a766fa5f60bca330ae65cc53a3c9c [ir][msl] Emit ir::Access by dan sinclair <dsinclair@chromium.org>
  - 3aaaaf476d6cdc5cd859c1ba3a8b924c91efd88c [tint][wgsl][fuzz] Parse base64 encoded comments by Ben Clayton <bclayton@google.com>
  - c97af9022e8442a2dbdea6716e190a04f3c18028 [tint][utils] Add DecodeBase64FromComments() by Ben Clayton <bclayton@google.com>
  - b421e4039ddf914ca55a1be0468b138bf7dc188c [tint][wgsl][fuzz] Fix static init ordering bug by Ben Clayton <bclayton@google.com>
  - ff67199151e64f4dc1f13a96aea80dd50c43d669 [tint][spirv] Add GenerateBindings() overload for IR modu... by Ben Clayton <bclayton@google.com>
  - f0973d594afb2563f044085764c448042ab6b1e1 [tint][utils] Add DecodeBase64() helper by Ben Clayton <bclayton@google.com>
  - 63eb5c8c26eef4692a2e99698e0b902cea82ecd0 [tint][utils] Add byte decoder by Ben Clayton <bclayton@google.com>
  - e988749ee42d12307483ea2fc6b89895845012e6 [tint][wgsl][lower] Skip over dead instructions by Ben Clayton <bclayton@google.com>
  - b098803b006d7d1bb7797fa08644acc9d31b6e1b [tint] Rename wgsl/wgsl_fuzz.* -> wgsl/fuzz.* by Ben Clayton <bclayton@google.com>
  - 1b48e6b4e1c7f0192554d3225959b26b524acc9d [tint][utils] Add byte reader utility by Ben Clayton <bclayton@google.com>
  - cea718c62b756d4cfce155460d5e629ca6918cf8 [ir][msl] Emit bitcast by dan sinclair <dsinclair@chromium.org>
  - 1fa6a4beb24243ad86bba906eca9c09e4cbb200d [ir][msl] Emit entry point stage name by dan sinclair <dsinclair@chromium.org>
  - 5555694d23e1507c24c76827003d765f6593ecf2 [ir][msl] Fixup binary emission by dan sinclair <dsinclair@chromium.org>
  - 24b81095d4bd758b87fb548c2ca1a3dcae2a2d74 [ir] Move use of IR decision higher in the stack. by dan sinclair <dsinclair@chromium.org>
  - 58794b5dfa9d81ef14122e3fbc85382664541b20 [ir][msl] Simplify expression emission in MSL printer. by dan sinclair <dsinclair@chromium.org>
  - 7bbe4c1696f2433d7228877d451b812e23c4adff [ir][msl] Add `construct` to MSL IR printer by dan sinclair <dsinclair@chromium.org>
  - 019146fbc300c5bd704dae7e198714ff774236d3 [ir] Add an IR option into the ICE machinery. by dan sinclair <dsinclair@chromium.org>
  - acef3106912878e0b93c0f969c80020853fcbbb1 [tint][ir] Add ConstPropagatingPtr - const-propagating ptr by Ben Clayton <bclayton@google.com>
  - eee3ad04f703c90c7af1a8f0ea358231247f955a [ir][msl] Add `discard` to MSL IR printer by dan sinclair <dsinclair@chromium.org>
  - 37e9d111b375bd014cb0e1236436b8eeea8da45a [tint] Namespace the strconv files by dan sinclair <dsinclair@chromium.org>
  - 1e7b312706ad214eb09007f77521488f0a409991 [tint][ir] Use 'const' on non-mutating IR consumers by Ben Clayton <bclayton@google.com>
  - c33fdbb0a4f4a8301551019596101c05e38249b3 Remove chromium_experimental_read_write_storage_texture by Jiawei Shao <jiawei.shao@intel.com>
  - ead8a043e377273b24e6c788007e6a7d15cf1093 [tint][ir] Add 'const' accessors by Ben Clayton <bclayton@google.com>
  - 1c483bfabb8685b5c1ff8c50b4d41677708b0d53 [spirv-writer] Fix atomics after discard by James Price <jrprice@google.com>
  - 69298a3abdb3e788e05931e961cb2337aab70c23 [spirv-writer] Fix implicit blocks with results by James Price <jrprice@google.com>
  - ffbcc3584f07dae21ff696bbdc9fdd26127e425f [tint][wgsl] Move RenameConflicts out of IrToProgram by Ben Clayton <bclayton@google.com>
  - a166dcb470df81ce26f1fde0fc3bc071c90aca87 [tint][ir] Simplify ir::Switch case generation by Ben Clayton <bclayton@google.com>
  - a89d6647f696b240bfd2861d79c7dba7d856dcb5 [tint][ir] Refactor Instruction result methods by Ben Clayton <bclayton@google.com>
  - fb07fa9e8877d3f7934ec972a4e7bd3a44e0a78c [build] Add guards for protobuf by Ben Clayton <bclayton@google.com>
  - e6744dbe784dbba68a866c3e6cf219ac616bfc40 [tint][utils] Add Vector(const Slice<const T>&) constructor by Ben Clayton <bclayton@google.com>
  - 0e21d289202eea9f08d14ca32cf3cdfa2cac8cca [ir] Fix Std140 for non-decomposed matrices by James Price <jrprice@google.com>
  - b9d3e1c8448ac3dc37fa2eac24d668dc1199b928 [tint][ir] Remove Block::HasTerminator() by Ben Clayton <bclayton@google.com>
  - 2e4b301ab516935dd2afc7e6e161e628a7ab2c43 [tint][utils] Vector improvements by Ben Clayton <bclayton@google.com>
  - 96687ce6fe09763f997a9ee5c345d04162a87451 [tint][ir] Remove Usage::Hasher by Ben Clayton <bclayton@google.com>
  - a86a8230eab47ce501c4bb4eb01b6cad5a9f456f [tint][utils] Change SymbolTable::Wrap() to be a static m... by Ben Clayton <bclayton@google.com>
  - 095c7c067792c0dc868a84f72b356723a43235d0 [tint][ir] Remove Module::disassembly_file by Ben Clayton <bclayton@google.com>
  - f2de7ead699d34b1ef8aa43398d5488ba67f018b [tint] Add build support for protobufs by Ben Clayton <bclayton@google.com>
  - 429e97b6d3f8caddd198154d0ad63c7ed5e96615 [tint][utils] Remove stray '+' by Ben Clayton <bclayton@google.com>
  - d67c378f26a756649984b6bd0eda1d752377e7e1 Revert "[msl] Remove PixelLocal as printer supported exte... by Ben Clayton <bclayton@google.com>
  - a87d06317a67c25c0676fc47fff87d9146622b5e Tint/HLSL: Support translating pixel local variables on H... by Jiawei Shao <jiawei.shao@intel.com>
  - 5896e7501bf3a0dccb12f146949195d461d4a71e [tint] Namespace the socket files by dan sinclair <dsinclair@chromium.org>
  - e5f014098bf1706bbf04f5a507ee8b8d04cbfba5 [msl] Remove PixelLocal as printer supported extension by Ben Clayton <bclayton@google.com>
  - 99672e2bf1edb05cc52a2fa5e9128952fd3a93e8 Use result type to handle diagnostics by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: 7e0d9e6843de383e721d2c269d6a64e3537a244b
Change-Id: Ic95378ba1d4e9efdc50c770088125baebd62efa5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/161020
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
525 files changed
tree: e1047948a0537bff7cacd84ef800f6de7da8377d
  1. .vscode/
  2. build_overrides/
  3. docs/
  4. include/
  5. infra/
  6. kokoro/
  7. scripts/
  8. src/
  9. third_party/
  10. tools/
  11. .clang-format
  12. .gitignore
  13. .gn
  14. AUTHORS
  15. BUILD.gn
  16. CMakeLists.txt
  17. CMakeSettings.json
  18. CODE_OF_CONDUCT.md
  19. CPPLINT.cfg
  20. DEPS
  21. Doxyfile
  22. LICENSE
  23. OWNERS
  24. PRESUBMIT.py
  25. README.md
  26. standalone.gclient
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.