Import Tint changes from Dawn

Changes:
  - 20d20f6f3f846793ddcec16fbed60a2bb7e97875 Allow @index Attribute On Variables by Brandon Jones <brandon1.jones@intel.com>
  - 54fc2a84e91ad8b89dce909922beb771b343c25d Recognize @index attribute when parsing by Brandon Jones <brandon1.jones@intel.com>
  - 4a38f0a803b9d2f653a39970b7fc187ca1becc1d Add @index Attribute to WGSL Writer by Brandon Jones <brandon1.jones@intel.com>
  - 3d9c5563be46145f153dbf8eec6afdd273e41580 [tint][ir] Swap order of first two BreakIf() params by Ben Clayton <bclayton@google.com>
  - 6130722a8173ec3d2d697faf4b52cb3055557521 [ir][spirv-writer] Add helper macro for unit tests by James Price <jrprice@google.com>
  - 407137aa46ed7b69e760a246a6d480e58fc4135c [tint][utils] Add bounds assertions to vector by Ben Clayton <bclayton@google.com>
  - 5735a675eb5fb259c0361cc06638d0a3ba994611 [tint][utils] Update doxygen for EnumSet by Ben Clayton <bclayton@google.com>
  - e04687a3e660e119ff2074511f81ab5f8ee03297 [tint][ir][ToProgram] Inline values respecting ordering by Ben Clayton <bclayton@google.com>
  - 3e65d908e9f82ea5e7dece9704af7ec00d2b28c8 [ir][spirv-writer] Rework unit testing by James Price <jrprice@google.com>
  - 084e2fdb43a5793f3de800c638b6970fae8947d1 [ir][validation] Add Unary validation by dan sinclair <dsinclair@chromium.org>
  - 027636e49941a54e8f0dd0a00f4104b441eb88ab [ir][validate] Extract operand nullptr checks by dan sinclair <dsinclair@chromium.org>
  - 9a51768e568ac1c0efe2d5c29f6a4b0142f43844 [ir][validate] Check functions only added to module once by dan sinclair <dsinclair@chromium.org>
  - 7686852fd55ed56f41074655a3aebdc408cf9334 [ir][validate] Improve result error messages by dan sinclair <dsinclair@chromium.org>
  - 54482355a5f020766c87967d518d64b21b768189 [ir] Add Builder::Var overload with name by James Price <jrprice@google.com>
  - ce882c00b218849f5bcadd2ba904362c123ec0e4 [tint][ir] Add EnumSet flags to Value and Instruction by Ben Clayton <bclayton@google.com>
  - 610e4e627af6a894cc148cef61b04b2136252953 [ir] Make Builder::Function add the function by James Price <jrprice@google.com>
  - 25b514646cd39d56c17bd25a361973aa4ab98d12 [ir] Add Builder::FunctionParam overload with name by James Price <jrprice@google.com>
  - 9e819bf9ea71646ec75e0d82d65c22e9a7d7cbdf [ir][spirv-writer] Handle shader IO by James Price <jrprice@google.com>
  - 4765e38cdc27112e4b1f06cea35acac4f66ab652 [ir][validation] Update binary tests to mark undef operands by dan sinclair <dsinclair@chromium.org>
  - 7257c563dd3855bf493b9d426d8e4231a4248be1 [ir][msl] Split long emit type switch. by dan sinclair <dsinclair@chromium.org>
  - 4f13d3116b40935cb79ed3dc717cc71bcb21fd6e [tint][ir] Refactor IRToProgramTest class by Ben Clayton <bclayton@google.com>
  - 0306088ebf79036a5b86669795e634c5a9c6956c [tint][utils] Add EnumSet::Set() by Ben Clayton <bclayton@google.com>
  - 5ef873a519434764d1fce835b9bdc0ce64332bb7 [tint][utils] Add UniqueVector::Erase by Ben Clayton <bclayton@google.com>
  - 607e241ba075f0de26793d52fc4c9b7de20f5632 [tint][utils] Add Vector::Erase by Ben Clayton <bclayton@google.com>
  - 45b59a8ba039f3df861bc63d5e02201884eb7932 [ir][msl] Emit struct constants by dan sinclair <dsinclair@chromium.org>
  - a356526632a54a28e93bc5d21f4130e230bd1fe3 [ir][msl] Cleanup duplicate emission code. by dan sinclair <dsinclair@chromium.org>
  - 676745988943cc9894b7e53dc5fea99ff90e1fa6 [ir][msl] Emit array constants by dan sinclair <dsinclair@chromium.org>
  - ae33f9722957ab97abde31a734b59b5c96dad494 [ir][msl] Emit matrix constants by dan sinclair <dsinclair@chromium.org>
  - c8a5cf8713eb32eb6a78a7d74f7075456deb0d64 [ir][msl] Emit vector constants types by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: 20d20f6f3f846793ddcec16fbed60a2bb7e97875
Change-Id: I18caa4521c6cdb96ee03707ffe202e9d81c71e58
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/139380
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
73 files changed
tree: 2f0f9f19646aaf6622882bb4898a85f78bd9fc7c
  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.