Import Tint changes from Dawn

Changes:
  - a187e9e281254475088161ca906a905282f5663e spirv-reader: Error for OpSpecConstantComposite expression by James Price <jrprice@google.com>
  - b703afc061cb518b81664c2fdb7f23570edf8934 tint/utils: Support hetrogeneous hashmap key lookups by Ben Clayton <bclayton@google.com>
  - 4204bb3ef11e2ea9d10a7a18f32a4ed69cf870a9 tint/writer/spirv: Fix build on MSVC / some clang builds by Ben Clayton <bclayton@google.com>
  - 1dd578ad35a3be57ffe3ef59bf45c6664b5d1ada Revert "ir/spirv-writer: Emit entry point declarations" by Ben Clayton <bclayton@google.com>
  - 146b67e0cdfae428a4787b0760b56649f49e9af6 tint/ir: Replace getter with raw fields for more classes by Ben Clayton <bclayton@google.com>
  - 895d240fbf9ec44dfd8900fa13b0aa2dc6dea880 tint/ir: Replace Converter with FromProgram() free function by Ben Clayton <bclayton@google.com>
  - 90789ea1f8f6aad42238dde3d75d39d8e07d0d60 ir/spirv-writer: Emit entry point declarations by James Price <jrprice@google.com>
  - 436fffe2a13cb8c4074fdd09944bc8b72a873788 ir/spirv-writer: Emit function declarations by James Price <jrprice@google.com>
  - c9734160bcf0509faf4f2a10296b8305fe1ba2a2 [ir] Add tests for compound operators. by dan sinclair <dsinclair@chromium.org>
  - eae9902c815a31bc0bcd4c465111fdf622c54ebe [ir] Add store test by dan sinclair <dsinclair@chromium.org>
  - 02b5b224e3d1591f9b9f7d53ec46779c90ecba7d ir/spirv-writer: Add support for scalar types by James Price <jrprice@google.com>
  - b169165633d5023111db83c22acaf71588d73f19 [ir] Add tests for unary conversion. by dan sinclair <dsinclair@chromium.org>
  - 63716c55cc4f6ea9872bf736a3d2b1e6d2a19d1f [ir] Spit builder_impl tests. by dan sinclair <dsinclair@chromium.org>
  - 34f41c7bad4ab5fbe90d9f6ca6e987e8333d3b2c [ir] Change unary not to a binary equal by dan sinclair <dsinclair@chromium.org>
  - e964f5163c9fe1cde50407c36aecde033079ce72 [ir] Update type display in disassembly, remove string me... by dan sinclair <dsinclair@chromium.org>
  - b298b6a222e2dddea59e4b126734976395d1be44 ir/function: Add missing <array> include by James Price <jrprice@google.com>
  - 29bff642fc0b1624350a78c673366934335a261b ir: Use std::optional::value_or to simplify code by Ben Clayton <bclayton@google.com>
  - f789854a94287fafd0b08abb9b67fe6bca95287f tint: fix undetected overflow in const-eval refract by Antonio Maiorano <amaiorano@google.com>
  - 8f9ea96c20734fb17d69576bfc4af7d7a224f466 tint/writer/spirv: Add path for generating from IR by James Price <jrprice@google.com>
  - 057b7f326e6383944e5ade235f2ee70d7fb568cd tint/writer/spirv: Use Diagnostics() for errors by James Price <jrprice@google.com>
  - cb8f3308a3e24388ee0e28ceb5a0b5bbeafdd24b spirv-reader: Error for OpUndef image argument by James Price <jrprice@google.com>
  - f885a90a5feabbf75ead60f60200098ea80adb9f tint/writer/spirv: Create Module class by James Price <jrprice@google.com>
  - 09b02ffc7bcb4b95f52315f1a11bfc833f69ec27 [ir] Split the Terminator into two nodes. by dan sinclair <dsinclair@chromium.org>
  - 69bb5dd816781b7490c9a3cc6a5de1f186bc9f2f [ir] Add function return information. by dan sinclair <dsinclair@chromium.org>
  - 9d9a38336e0571ce6fa6fccd2e7868fcc341c04a [ir] Add function attributes by dan sinclair <dsinclair@chromium.org>
  - 4cadbc4daf9fea260feb80f570674a9f71d7d50a [ir] Handle IdentifierExpression by dan sinclair <dsinclair@chromium.org>
  - 1545ca191bd5b4a9f31e10c9924e7cdbc395ea29 tint: Remove Program|ProgramBuilder::FriendlyName() by Ben Clayton <bclayton@google.com>
  - 6ac51c1c572d0327e62c53f6eeac388279cf9aec [ir] Update binary and unary names. by dan sinclair <dsinclair@chromium.org>
  - fa00fe9d417fbbbfcdae4390a85faedc9dc6dfb0 tint/hlsl+glsl: fix workgroupUniformLoad polyfills by Antonio Maiorano <amaiorano@google.com>
  - e903396ff2c5d4c205bffc5c6b91cb48ebefd5f7 [ir] Emit short-circuit as an `If` node by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: a187e9e281254475088161ca906a905282f5663e
Change-Id: Iab6728a5ca72ed77818aa6bb5095315ba47fa4a8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/131680
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
143 files changed
tree: 4b95792795a49ab18aec5876ded5857fa16ebfd8
  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.