Import Tint changes from Dawn

Changes:
  - ee3f7fad742fec0b4b801b8a3f16a53f90342cdb [tint][fuzzers] Fix bug in tint_common_fuzzer.cc by Ben Clayton <bclayton@google.com>
  - 44266d59c84fa5bc4c36112b1eb81b5686587a6a [ir] Guard SPIR-V transforms in build files by James Price <jrprice@google.com>
  - f83bfa869cafb740aa3db16526aa26230c42d7f4 [ir][spirv-writer] Polyfill the `dot()` builtin by James Price <jrprice@google.com>
  - 128a76662848af2df627d8a33c59da2a154556e5 [ir][spirv-writer] Polyfill the `select()` builtin by James Price <jrprice@google.com>
  - 4e6a3f49b7c777c7c02217d4010a1b484098c618 [ir] Add IntrinsicCall instruction by James Price <jrprice@google.com>
  - 4e634e98ff3d2de1cdcf9fcf532e5d4a2d1e17df Make Canonicalize Entry Point Transform Compatible With @... by Brandon Jones <brandon1.jones@intel.com>
  - 3c8c6c91e093d24cf188188a6df6d0de1ddafdf3 [tint][ir][ToProgram] Implement discard by Ben Clayton <bclayton@google.com>
  - a6f4b958a1f9bcc5d660826be67c6d684f192376 [tint][ir][ToProgram] Emit phony assignments. by Ben Clayton <bclayton@google.com>
  - dc288ed43d74b8b443ff91a88aa5a70aa189dcfa [ir][spirv-writer] Handle discard in SPIR-V writer by James Price <jrprice@google.com>
  - 6761d7a8912fc427dba2e35e1f1eb486edf801e0 [tint][ir][ToProgram] Fix vars with handle address space by Ben Clayton <bclayton@google.com>
  - 534ccf06728d310acbdf7d33a1af9b4a4d9e5b00 [tint][ir][ToProgram] Assign builtin calls to phonies by Ben Clayton <bclayton@google.com>
  - eb308398ea665d36e184459bf15fb2d6d36ca196 [tint][ir][ToProgram] Fix pattern matching for loops by Ben Clayton <bclayton@google.com>
  - 745180ede4c6d3d0e720af1a633377190d4e0e1b [tint][utils] Add Vector::Insert() by Ben Clayton <bclayton@google.com>
  - 3adb3217b0864b924c4e80f97577fc6ff72dc847 [ir] Implement demote-to-helper transform by James Price <jrprice@google.com>
  - a8fce7c8e76efe1eabf2ebb1b773ab36c5d2f39a [tint][ir] Add LoadVectorElement / StoreVectorElement by Ben Clayton <bclayton@google.com>
  - 4bb65162986a356163f143153cf02251b36ec61c [tint] Move builtin utilities to builtin namespace by James Price <jrprice@google.com>
  - 4574f07edf953ab20f6cbe18c2474245498fcf50 [ir][validation] Add ExitLoop validation by dan sinclair <dsinclair@chromium.org>
  - 8c74eb124f6ff148e9c8ef9c9280b18e8f515325 [ir][spirv-writer] Implement fract builtin by James Price <jrprice@google.com>
  - a7157be4ce53bcb489cbbd67769961203fd7a598 [ir][spirv-writer] Implement frexp and modf by James Price <jrprice@google.com>
  - 881c0b402458f97b8f750e4fc9022828a0b70ef4 [tint] Refactor builtin struct type creation by James Price <jrprice@google.com>
  - 831ad31fbf3ce5d0774a82128b8cedfe9e3e0c93 [tint][ir][ToProgram] Fix EXPECT_WGSL() failure message by Ben Clayton <bclayton@google.com>
  - 8a319bf369b58762b0efc029073c7edeec774ac4 [tint][fuzzers] Apply SubstituteOverrides to ir roundtrip... by Ben Clayton <bclayton@google.com>
  - 165fdaa483f3c20050f3d523f464a39019fd432a [ir][validation] Add ExitSwitch validation by dan sinclair <dsinclair@chromium.org>
  - de3b699b935923b60c527b9b216252ed7e41a144 [ir][validation] Add ExitIf validation by dan sinclair <dsinclair@chromium.org>
  - 75bc633f02dbf1cfd4acb9d70e4368096f6e4626 [tint][ir][FromProgram] Refactor inc/dec/compound assignm... by Ben Clayton <bclayton@google.com>
  - 012cb28daccb5df7bbfbc02d0e390827ce8c6bf4 [tint][sem] Add new AccessorExpression base class by Ben Clayton <bclayton@google.com>
  - 6d3bf1ac0ccf606fb339ca47c3d756e3f04dc163 [tint][ir][Builder] Prevent coercion to Constant(bool) by Ben Clayton <bclayton@google.com>
  - 44f810e3cad59fb892187e149ee653b994b5339f [tint][ir] Add more to/from program tests. by Ben Clayton <bclayton@google.com>
  - 0e8939aaa4aef4b45fac875fb10b08793c1819b1 [tint][utils] Add Vector::Reverse() by Ben Clayton <bclayton@google.com>
  - 707a37edda4ff2988c481142da4bcacafd07f6d3 [tint][ir][ToProgram] Fix member accessors by Ben Clayton <bclayton@google.com>
  - 15cbc3f229435c3a97401085f0625a7bc913a3df [tint] Fix build by Ben Clayton <bclayton@google.com>
  - 56343feb6de0794f2869b1c6a90c59ff28e052a7 [tint][ir] Add ir::Let for giving values a name & position. by Ben Clayton <bclayton@google.com>
  - cc2c7781b49d5d4e89a08e6f2fd6ea12ed6ef67f [ir][validation] Remove operand names by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: ee3f7fad742fec0b4b801b8a3f16a53f90342cdb
Change-Id: If3e1d294fa440fecfee96c90c706b273e60fe2d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/140921
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
79 files changed
tree: e71c5e3dfef636a59ce2def23536b7b55f147188
  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
  27. 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.