Import Tint changes from Dawn

Changes:
  - d7b8efa431ad32b22fa48177ba85def3435b11ad [ir][spirv-writer] VarForDynamicIndex transform by James Price <jrprice@google.com>
  - 7967019cfd7f8b5095e5466798cc90bcd08d69c5 [tint][utils] Add Offset and Truncate to Slice by James Price <jrprice@google.com>
  - 117d4f387ec570b52887e0a447e7d8d404b02a7a [ir][spirv-writer] BlockDecoratedStructs transform by James Price <jrprice@google.com>
  - 2f7c540ec52185a55e4e4b39b69f9e24373824e9 [tint][utils] Allow assignment of Slice to Vector by James Price <jrprice@google.com>
  - b984643f1c0ae6e3758a10d7aa543616fbfa1281 [ir] Emit disassembly from the validator by dan sinclair <dsinclair@chromium.org>
  - 7b6fd80c3576b9f040fd4b9f06d19f8cfe9e486f [tint][ir] Add ControlInstruction by Ben Clayton <bclayton@google.com>
  - aa78dcd4c94ec2aa474ff1a2d26416ad313d3716 [ir] Emit struct declarations in the disassembly by James Price <jrprice@google.com>
  - 879e948d69a7fa598cff4c31737a69f3ae617074 [tint][ir] Add Initializer block to ir::Loop by Ben Clayton <bclayton@google.com>
  - 79899ef43883484062ceeef0209f50def7b3386c [tint][ir] Add Front() and Back() accessors to Block by Ben Clayton <bclayton@google.com>
  - b165466d8e957ea33bb57127f2ae9237e7082b0e [tint][utils] Change return type of 'Vector::Slice() const' by Ben Clayton <bclayton@google.com>
  - 7207e7108305b258e40dbdf6385b07eeef067fa6 [ir] Add SetOperand() to ir::Instruction by James Price <jrprice@google.com>
  - e040ca685af2925b7bb0673b16c88ff5ed4071bd [ir] Add Value::RemoveUsage() to remove a usage by James Price <jrprice@google.com>
  - 8e2ca44835f5d8e7f1e223033094f16d816e5a81 [tint][utils] Add Hasher specialization for VectorRef by Ben Clayton <bclayton@google.com>
  - 2114131d0f5ac6bb64bf2ef241851982937f68f4 [ir] Track the operand index for value usages by James Price <jrprice@google.com>
  - ae8a9f9f55c471f5136d11fb96277ff854e7a42f [ir] Add OperandInstruction class by James Price <jrprice@google.com>
  - 03b708ad0ae42f365fd3d03f66c06e38b8623747 [ir][to_program]: Implement unary & binary ops by Ben Clayton <bclayton@google.com>
  - f2c55d792dfc635a4570d370a71278dbf31da1d2 [ir][to_program]: Implement fn parameters by Ben Clayton <bclayton@google.com>
  - efdcbdfc899944adddc3a72ea3e8ae37728e1774 [ir][spirv-writer] Emit access instructions by James Price <jrprice@google.com>
  - 0a99719ad014347d96d3e76b5571370ef7dc1af8 [tint][utils] Add casting constructor to Slice by Ben Clayton <bclayton@google.com>
  - cff18f3ec89141714c1e93ab325a290f21b7bc3e [ir] Add validator to spirv tests. by dan sinclair <dsinclair@chromium.org>
  - fb0466e046fea4f27dcc233b40cf07c3eeb0b39b [ir] Stub out validator checks. by dan sinclair <dsinclair@chromium.org>
  - 5baa4b41c352cdff713a68a922ce08a5bf9640f8 [ir][to_program]: Simplify error handling by Ben Clayton <bclayton@google.com>
  - eefa7fe22c1e63d6a04f79074b0307e432f03e20 [ir] Add guardrails to IR classes. by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: d7b8efa431ad32b22fa48177ba85def3435b11ad
Change-Id: I4afa1d1c244e73e860162cc133e5e17189ae8193
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/136120
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
126 files changed
tree: bb9aeec416ccc14ac379c5cb3c1276eee3bd20f5
  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.