Import Tint changes from Dawn

Changes:
  - 1a8a19deddb55155846beee9d262fd8ebe00385d [tint] Rename pointer builders to 'ptr', match WGSL order by Ben Clayton <bclayton@google.com>
  - 2c27e79d4b7e1cb6a04f3b55776d815bcb609bf0 [tint][resolver] Fix short-circuiting of const identifiers by Ben Clayton <bclayton@google.com>
  - 4b8a3d34d4e5185c580ca613dbdd4e84ba78f3c8 [tint][transform][hlsl] Fix bad materialization by Ben Clayton <bclayton@google.com>
  - cf2cf156c4f5fee47bd4e6c8e4cdf2332bac3ee8 [ir] Remove old `Load` constructor. by dan sinclair <dsinclair@chromium.org>
  - 455e4b80f6b8d065660ced359bf836f72c656f33 D3D12: Always skip Robustness transform on non-DBO storag... by Jiawei Shao <jiawei.shao@intel.com>
  - f3a03513bd3c8c9224d2a5992e8d768a4016018f [tint][type][ir] Add fluent type constructor helpers by Ben Clayton <bclayton@google.com>
  - b768af431559c05ef71fd4de28cbbad5e88f9de2 [tint][ir] Use new fluent builder methods by Ben Clayton <bclayton@google.com>
  - 039ffdc9c79825c27aca6f4631610b5f5ce4f8ae [tint][ir] Rework Builder to allow for fluent args by Ben Clayton <bclayton@google.com>
  - c67a4fa78094b1b79027148f9250c27064bf9d95 [tint][ir] Strip Create prefix from methods by Ben Clayton <bclayton@google.com>
  - 4abe1b0cd66a56b5f47b7bb7562672f69789fa2b [tint][ir] Simplify Convert by Ben Clayton <bclayton@google.com>
  - 1d0ac04a729edefdc75a15ae89b362f65b3fe4e3 [tint][ir] Rename Builtin and rename Builder Call methods by Ben Clayton <bclayton@google.com>
  - bc3111cc84d29603e0d390b80dfc928c4f9ee4f1 [tint][disassembler] Trim 'note' source to block start by Ben Clayton <bclayton@google.com>
  - d3fe5f542f0b4402131470c62948b83db06e6ee7 [tint][ir] Validate Access instruction by Ben Clayton <bclayton@google.com>
  - 7d7dce35bb0b567a83da1742d02514a7c6fddc6f [ir] Builder::Return takes single Value by James Price <jrprice@google.com>
  - 1c9a507b2003560230b7f8df397a6c4e3177cabc [ir][spirv-writer] Use Type::Element() by James Price <jrprice@google.com>
  - 8f7092ebe46deda3cbb61c80700a360bdaa7cd60 [tint][type] Add Element(uint32_t) by Ben Clayton <bclayton@google.com>
  - 471a015c5b8b6afe318d57f9e354934f7b7219df [tint][type] Rework ElementOf() and DeepestElementOf() by Ben Clayton <bclayton@google.com>
  - a5268dff5477b3b7b8bed8216020b0d0b46a5ef7 [ir] Unconst most of the IR. by dan sinclair <dsinclair@chromium.org>
  - 5c9fd76edd8cbbcd178fca81aa9de3be865f4098 [tint][type] Add NumericScalar base class. by Ben Clayton <bclayton@google.com>
  - 1416b18116faab4b1e1349f0de58d792edd24bab [tint][type] Add Scalar base class. by Ben Clayton <bclayton@google.com>
  - bed3fe068c18e42a2b832145e0caac7c6b666928 [ir] Address review comments in VarForDynamicIndex by James Price <jrprice@google.com>
  - be3125eb3c6fef4d0760201d4ba5cb8bd5ec33db [ir] Add Value::ReplaceAllUsesWith helper by James Price <jrprice@google.com>
  - 55aff4e5ef8787d597646a897a0a9a5646eb3f4e [ir] Return instruction from Block::Append/Prepend by James Price <jrprice@google.com>
  - e6b4a908d2e98aeaee2efdbb957c267d3ea2418f [tint][ir] Rename Builder.Declare() to Builder.Var() by Ben Clayton <bclayton@google.com>
  - d2e30d0df26be3075de7319eb1ccc124672b63de [tint][ir] Change Var::Type() to return type::Pointer* by Ben Clayton <bclayton@google.com>
  - 0ebf677dfe216d923a5e233accb419b9182c4bb0 [tint][ir] Add MultiInBlock that derives from Block by Ben Clayton <bclayton@google.com>
GitOrigin-RevId: 1a8a19deddb55155846beee9d262fd8ebe00385d
Change-Id: Id7732faab084bb70e8c323f329c3e812a3bb0b7f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/136720
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
222 files changed
tree: eca20556b44432adf7f4ce2ba8f3f53fa739a07d
  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.