Import Tint changes from Dawn

Changes:
  - 8f80d999c4738aef4f8d6664468e411c6b96df26 tint: Support multiple extensions per 'enable' by Ben Clayton <bclayton@google.com>
  - ed28de3c53937fd6c0824f534b66cdcea7c437a7 tint: Support @diagnostic on for loops by James Price <jrprice@google.com>
  - 9536ced0148a1c645f595326201200bb1fbe6975 tint: Support @diagnostic on while statements by James Price <jrprice@google.com>
  - d0ed63eb64f7761eaf9414fbbbe2a0e1f13e3f7a tint: Support @diagnostic on switch statements by James Price <jrprice@google.com>
  - 0607796ef8e26124299df34abf5f5a5a8803425e tint: Support @diagnostic on if statements by James Price <jrprice@google.com>
  - a370186824298735bac70a710815ae32f00a213f tint: Fix compilation on latest MSVC by Antonio Maiorano <amaiorano@google.com>
  - 1f6ce67ed28881b9a4a42713474120224eb6871d Move `clamp_frag_depth` transformer to backend. by dan sinclair <dsinclair@chromium.org>
  - 6521a357f5a54e1ed6296170beb1d8a90a015111 Convert generators over to use external texture options. by dan sinclair <dsinclair@chromium.org>
  - 97382d96f5b21e17be317ca048b69dfc11be33ce tint: Validate no template args with functions / builtin ... by Ben Clayton <bclayton@google.com>
  - 6784a5276639cda54003d15656de5c10b103030d Sync keyword/reserved word list. by dan sinclair <dsinclair@chromium.org>
  - 7bca4d72938a96abd493438e8ca0e1423ea5f20b tint: Remove constant::Value::AllEqual() by James Price <jrprice@google.com>
  - 69253ee8a527594ffc64732b608abbddb6075273 tint/uniformity: Move recently added tests by James Price <jrprice@google.com>
  - 8cb5ed8c2c48ec856b7c83f06ea5f9b077dc8230 tint/uniformity: Fix compound assignment LHS eval by James Price <jrprice@google.com>
  - 79d0f2b78435ab8e1b2e393d1e22274c249a5e24 [ir] Add `ir::Builtin` by dan sinclair <dsinclair@chromium.org>
  - cd097f40a3bf40b32324ba58913066dc5be95c18 tint: Improve module scope var diagnostic by Ben Clayton <bclayton@google.com>
  - e95b59c34dcabb38db618f25e2e9137ca77306ed Add ExternalTextureOptions by dan sinclair <dsinclair@chromium.org>
  - a36fa42dd73ce65491030331d4961a7af9de14f9 tint/cmd: Use correct preprocessor guard for libspriv.hpp by Ben Clayton <bclayton@google.com>
  - 574b4b19964714444836fa5c391a265266dcfdcb tint: Fix constant::Splat conversion of struct types by Ben Clayton <bclayton@google.com>
  - 7972a10aa8f3686c9b9d7f69fc9b18d9db53d3e7 tint: Add missing include by Ben Clayton <bclayton@google.com>
  - cc3f851ad8f2e15f917a04f8543310a6c06af2c7 tint/transform: Polyfill f32 conversion to i32 or u32 by Ben Clayton <bclayton@google.com>
  - f1f56b2d3ca8201ec7e9c2cbcabb565655a5ba15 tint/writer/glsl: Set default precision to highp by Ben Clayton <bclayton@google.com>
  - 4fea9d0fbbcd1a88cf59e8b39ff7064a16e46a19 tint: Implement Switch() without recursion by Ben Clayton <bclayton@google.com>
  - 23946b36060b87a622a93e0331777c171b95d643 tint: Move Switch() to own header by Ben Clayton <bclayton@google.com>
  - 9543f74739118a853dd5e5a46297f5442c3352f8 Move sem::BuiltinType to builtin::Function. by dan sinclair <dsinclair@chromium.org>
  - 03ee23ea9efa2c4d053cb2c23152fc23553a3eaf [ir] Convert materialized nodes to constants by dan sinclair <dsinclair@chromium.org>
  - 2657b923c91b7e8a6259d80895dbae1d9f6c58d8 tint/writer/glsl: Fix vector `select` by Ben Clayton <bclayton@google.com>
  - da353b4b391e1ed4527ca43f9e36ab2b3c463f1d tint: Flip evaluation order of assignment statements by Ben Clayton <bclayton@google.com>
  - 43c5efa7e813dab3b7991cdbc901dce4c639b64f [ir] Add error helper to ir builder. by dan sinclair <dsinclair@chromium.org>
  - 724a70f7a19862250bef6355203b024dbd431e35 [ir] Add user functions, value constructors and value con... by dan sinclair <dsinclair@chromium.org>
  - 51be3420b89f36ce3a9e27306dc0743915e2153b tint/writer/glsl: Fix emission of lowest i32 value by Ben Clayton <bclayton@google.com>
  - ce2578bc993371e473fe6f9801a2c287a5f8ad64 tint/transform: Refactor BuiltinPolyfill transform by Ben Clayton <bclayton@google.com>
  - eebbdef81a2a112126c6eb66e21be9dd3c5d5b1e Split `BindingPoint` out of MultiplanarExternalTexture. by dan sinclair <dsinclair@chromium.org>
  - 068eb3ebdaf66b47264392bfbc708f871d0b45ee tint: Fix HLSL texture queries and re-add textureNumLayer... by Ben Clayton <bclayton@google.com>
  - 0917fbb1472a7ffcbf614b63b1ee8dca1758ffa5 Reland "Add writer to emit the AST." by dan sinclair <dsinclair@chromium.org>
  - 2fe7f19026088e7cd0d1510f44fbcd4aef925c21 Use `absl::from_chars` instead of `strtod` by dan sinclair <dsinclair@chromium.org>
  - 64196ad60adfc7f831485ac7b592b8cd5f865a55 Add array length options header to `tint.h`. by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: 8f80d999c4738aef4f8d6664468e411c6b96df26
Change-Id: I05826385293df952c7c1bbc5b8703614ea5a7cdd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/123080
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
201 files changed
tree: 92ded67d22da44a7a323e65f8f854a46b83e233e
  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.