Import Tint changes from Dawn

Changes:
  - 2de4deea1f4de5bae44be624e0ec88060e8aae60 tint: Fix implicit conversion of vector-scalar of abstrac... by Antonio Maiorano <amaiorano@google.com>
  - fa4a7291f2f6083b72a09cb4d944e68c109f8e2b tint: add [[nodiscard]] on utils::Result class by Antonio Maiorano <amaiorano@google.com>
  - cc937971c9ff16d905f59f9c23ae38f7bcb0c94f tint: natvis: add utils::Slice, utils::Vector, and utils:... by Antonio Maiorano <amaiorano@google.com>
  - 735e4b4fa1ef359f2db9308522f5715a3130debd Emit deprecation for fallthrough. by dan sinclair <dsinclair@chromium.org>
  - 4acf608cf2268dc894480bc8d125098e944e553c Include 'libfuzzer_exports.h' in fuzzers that are missing... by Ryan Harrison <rharrison@chromium.org>
  - 3abad2c1257df4d7499914241acf70d03fc2141e When emitting a MSL struct initializer emit the struct na... by dan sinclair <dsinclair@chromium.org>
  - a58d8c9facbf55291dfa90edaf21a7c67cd7cc6e tint: fix builtin calls and binary ops with abstract args... by Antonio Maiorano <amaiorano@google.com>
  - 90d5eb612895d143791aa3527832fcefa57a2b99 tint: Add RemovePhonies transform to spir-v backend by Antonio Maiorano <amaiorano@google.com>
  - b91d7e1b31be193bdeb3a240cd1ae9f09782b290 Spit `expect_variable_ident_decl` into helper and calling... by dan sinclair <dsinclair@chromium.org>
  - 7058a17bda91e64f3c46b8330466776ee585af91 tint: refactor ConstEval API to accept vector of constant... by Antonio Maiorano <amaiorano@google.com>
  - a8e9a6ef2bd6391bce2460d0b544847f4b70eae2 tint: Fix Resolver erroneously materializing matrices of ... by Antonio Maiorano <amaiorano@google.com>
  - 50bc60359ee103f8096e04aa3a6d09c28d481fe5 tint: Add unit test for HasSideEffects for builtins by Antonio Maiorano <amaiorano@google.com>
  - f7e2de797145279ca568f7eed514ba20584756be tint: make RemovePhonies remove call statements to builti... by Antonio Maiorano <amaiorano@google.com>
  - e62fbbc75cfd0e131dd2ed5979290b1dd4863590 Syncing WGSL grammar to Tint. by dan sinclair <dsinclair@chromium.org>
  - 6d5542d7036730f268bf1deb2d566ba815436caf Fix compilation error in delete_statement.cc by Corentin Wallez <cwallez@chromium.org>
  - 1884c964d7e64ff97f69c8e1240d1073dace1ad7 tint: Fix utils::Vector<T, 0>::Push segfaulting by Antonio Maiorano <amaiorano@google.com>
  - 953d610aa2244604a271be3bddd7c609337241df AST fuzzer: mutation that deletes statements by Shiyu Liu <jamessliu2020@gmail.com>
  - 20cddbf04ca6bbca806bd24ef201d1e714d88448 tint: Implement modf and frexp built-ins for f16 types by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - 1cd4706f850edefc7f12c82b041621daf94b21fa Sync the `statement` grammar element. by dan sinclair <dsinclair@chromium.org>
  - 7d8307122e6cdc6c66b3da8e6d7eaa52a2cb54f1 Cleanup some strings; Reorder `attribute` rule. by dan sinclair <dsinclair@chromium.org>
  - 69a9415084dabdf140aa6efafe88deda784e2b66 Extract interpolation sample and type name parsing by dan sinclair <dsinclair@chromium.org>
  - 737fd8223ebab063da09281295ede8bad02db378 Add `expression` into the WGSL parser. by dan sinclair <dsinclair@chromium.org>
  - 7e9f571814c720b887f63870628c03e5e3102757 tint: const eval of binary add by Antonio Maiorano <amaiorano@google.com>
  - b8893b4c2f8a7f018fa55bc8cddeceb4c10d8e7c Sync the `global_decl` grammar rule by dan sinclair <dsinclair@chromium.org>
  - c2a052eaa4453eeb9c797b6f576143bdcf3b26a8 tint: Allow ConstEval functions to fail by Antonio Maiorano <amaiorano@google.com>
  - 50bddbffca5e50e82741d2b203f74a94c009a17c tint: Fix dxc on Linux by Antonio Maiorano <amaiorano@google.com>
  - 50940aeef1da1feccff97b94c9c800f3fafcaf36 tint: add CheckedAdd AFloat overload by Antonio Maiorano <amaiorano@google.com>
  - f3015a81cc35f06226545f4de59164531997b92f tint/reader: Parse static_assert by Ben Clayton <bclayton@google.com>
  - 7d7976d590fe95a0e500e235d3cb78c5997a2f53 tint: Add end-to-end tests for expressions using f16 types by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - 7d04cedce3f197109d076cddbccf8db90d3a1f98 tint/resolver: Pre-allocate containers by Ben Clayton <bclayton@google.com>
  - 6d6692105303da31ac0df301f621ecae834863f7 tint/resolver: Reduce small-vector sizes by Ben Clayton <bclayton@google.com>
  - b4744ac3599ae1691e1f8be9f4feb162b6e5de21 tint/writer: Handle static_asserts by Ben Clayton <bclayton@google.com>
  - 759ac33cd177a74b4f82ace7ead6f02a70dd65ed tint/resolver: Optimize intrinsic lookups by Ben Clayton <bclayton@google.com>
  - 6f8d945dd6ce5d786530c1b2b8bdb2140616cbed Sync reserved token list to WGSL spec. by dan sinclair <dsinclair@chromium.org>
  - 02791e95f3ae8f0536d7b5067704ad3332387251 tint/resolver: Resolve static_assert by Ben Clayton <bclayton@google.com>
  - bfd1a81364f0718f806ab01b2eaa673e1b2cc642 tint/ast: Add StaticAssert node by Ben Clayton <bclayton@google.com>
  - ce6246502c4d4e43b158bd161859179ba606bf75 Add `global_directive` rule to the WGSL parser. by dan sinclair <dsinclair@chromium.org>
  - ab5fc1c4dcdc0f5ac69b463bf18d15112c2326ee Fixup utils::Vector merge conflicts. by dan sinclair <dsinclair@chromium.org>
  - 73778d3b0bd7cb49d3cc9c165c8f4bf7c3017b9d Add support for >>= and <<=. by dan sinclair <dsinclair@chromium.org>
  - 783b169bf47b9fe7a0af7e86381bb4c1b95b3128 tint/ast: Migrate to utils::Vector by Ben Clayton <bclayton@google.com>
  - 34d46731bbc4270086e585186a8cda9e5ed9e02f tint: Replace VectorRef with ConstVectorRef. by Ben Clayton <bclayton@google.com>
  - 4abf28e29b515cbdadba2c83949059bf94f879b5 tint: Add basic support for chromium_experimental_push_co... by dan sinclair <dsinclair@chromium.org>
  - 24d36b022747fddcd345eeecd0767ac68bcaf204 AST fuzzer: fix change unary operator mutation by Alastair F. Donaldson <alastair.donaldson@imperial.ac.uk>
GitOrigin-RevId: 2de4deea1f4de5bae44be624e0ec88060e8aae60
Change-Id: If080953641c8de4363964e89fb685210d6a9c57d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/98063
Commit-Queue: Copybara Prod <copybara-worker-blackhole@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
362 files changed
tree: 8c83e18441f03266c3620abe958815b55e63ca44
  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.