Import Tint changes from Dawn

Manual fixes:
- Add DXC to DEPS
- Add `dawn_dxc_dir` to `build_overrides/dawn.gni`
- Add TINT_WERROR definition and use it to enable -Werror

Changes:
  - 1ea04e752a1f85df223e0ba0d2b049a130167fcb [tint] Avoid using function source in diagnostics by James Price <jrprice@google.com>
  - 8a594c537587331be4a3c48d9d53717a5cccf461 [tint][ir][fuzz] Fix ClampFragDepth fuzzer by Ben Clayton <bclayton@google.com>
  - 5976efe6b4b72c822085cf7ee08ad00036888ab5 [tint] Link libraries for dlopen by James Price <jrprice@google.com>
  - 8752d497a948919675cbd4e7c539b0123211c28c [tint] Fix TINT_BEGIN_DISABLE_ALL_WARNINGS for GCC by James Price <jrprice@google.com>
  - 1888e152b77a3870d4c930d0fc2bb0828f9e1ffb [tint][spirv] Remove use of locale by Ben Clayton <bclayton@google.com>
  - de601a8efdbbdeb56c97c8d44bc34bba63be4b2c [ir] Add Function::AppendParam() helper by James Price <jrprice@google.com>
  - d9ca1a8b1a64c83775ceb4f9274f209b7c86a491 [uniformity] Fix ICE for pointer parameters by James Price <jrprice@google.com>
  - 6be95cec0b75d0d08cba9b56f56d4ed4ee5ee64e Refactor Inspector::GetTextureQueries by Shrek Shao <shrekshao@google.com>
  - c45c5d233a48501220d4e7252e836590128c72cd [msl] Refactor barrier polyfills by James Price <jrprice@google.com>
  - 1450d1d7f79b7f684bdac5196c3e06a86655034f CMake: Compile without -Werror by default. by Corentin Wallez <cwallez@chromium.org>
  - d3bebe6cf996439ed197d1c83e323baf8a9a7135 Support Coord Transformation for TextureLoadExternal() by Yan,Shaobo <shaobo.yan@intel.com>
  - 4975e45e94803c81563f0c290585a526d4c089d1 [spirv-reader] Handle OpIAdd instructions by James Price <jrprice@google.com>
  - 15445d1cbae1fef071af596f4b94faa1a5f7c709 [spirv-reader] Accept DepthReplacing by James Price <jrprice@google.com>
  - 92c7dbe391f09d42c2c081b96f00a5cb7bffe34d [tint][exe] Use `lower` when reading SPIR-V to IR by James Price <jrprice@google.com>
  - 2ee454636849c6debbc85f147a4cdf9d023ce43d [ir] Fix TINT_DUMP_IR_WHEN_VALIDATING by James Price <jrprice@google.com>
  - c410a83088d21c03d94e8058ac727c91364b7220 [tint][ast] Skip ClampFragDepth fuzzer if member offsets ... by Ben Clayton <bclayton@google.com>
  - 10d27c4c5ec062424acebd221d57a9fa3a670336 [spirv-reader] Handle OpFMul instructions by James Price <jrprice@google.com>
  - 9531d78bcf74288ae6d3ebd1132a15282a793857 [spirv-reader] Handle OpFAdd instructions by James Price <jrprice@google.com>
  - 415bd731243a5714a60064648b66f8e4491f47fe [tint][diagnostics] Remove System enum by Ben Clayton <bclayton@google.com>
  - 9dc707121317b1c7481f6ae0425c716ab1dc8bbb [tint][diagnostics] Remove ICE / Fatal severities by Ben Clayton <bclayton@google.com>
  - 5bd57050e50f0480d7753e9589cd4f28328185fa tint: make FindExecutable look in explicit CWD-prefixed p... by Antonio Maiorano <amaiorano@google.com>
  - 5350eb99d6d11d3f4d2bf1942d176277eb043621 hlsl ast fuzzer: validate hlsl with dxc by Antonio Maiorano <amaiorano@google.com>
  - 2f84301ccb3e4e2eb67c44b253510466094c4fc9 [tint][ir] Set the File on Disassembly's Sources by Ben Clayton <bclayton@google.com>
  - 3aebf9ec38e16b4717aa52382c7f7d47a510efba [tint][ir] Validate value scoping by Ben Clayton <bclayton@google.com>
  - c28fff58849a1447fe87e558550561706258e4f4 [tint][fuzz] Support passing fuzz::wgsl::Options to the W... by Ben Clayton <bclayton@google.com>
  - 833b892ea02779af23e83a244eaa445b5f4c6eb7 [tint][ir] Validate blocks without using recursion by Ben Clayton <bclayton@google.com>
  - 9d2a27af4a05926c5fee2e245883c61b1e6d5bec [tint][ir] Don't use capitalized diagnostic messages by Ben Clayton <bclayton@google.com>
  - 35db5b565e3a043b33b05c211447b016edc12acd [tint][ir] Have the Validator use the Disassembly::NameOf() by Ben Clayton <bclayton@google.com>
  - aaeb83a4fbcd6d5cf04cf62a837270326c3cf7f7 [tint][ir] Refactor the Disassembler, rename to Disassembly by Ben Clayton <bclayton@google.com>
  - 4ac690d07be2dfa1fee676558514c11a9d392571 tint_cmd: use DXC via shared library (dxcompiler) rather ... by Antonio Maiorano <amaiorano@google.com>
  - 9ae003a28e62d882e6bda2ea1a998dfea61b6bc9 [ir] Remove unused worklist by James Price <jrprice@google.com>
  - 425cb428fa9598dcdb549256f6a626236f64344c [tint][ir] Use styled text in validation errors by Ben Clayton <bclayton@google.com>
GitOrigin-RevId: 1ea04e752a1f85df223e0ba0d2b049a130167fcb
Change-Id: I6c6a440e3ecdc72a40f0d8726146eee07ee76e2e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/186661
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
123 files changed
tree: 96567119d7ac05d990cb7fb24e6ff8c538e59275
  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. LICENSE
  22. OWNERS
  23. PRESUBMIT.py
  24. README.md
  25. standalone.gclient
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.