Import Tint changes from Dawn

Changes:
  - 558f0dfed76840e3793d2468b3b504d465b8ee89 [tint][fuzzers] Port ast_printer_fuzz to tint_wgsl_fuzzer by Ben Clayton <bclayton@google.com>
  - 0619b8c5f6712425ba382aeca9465a607b8a5559 [tint][fuzzers] Port tint_ast_clone_fuzzer to tint_wgsl_f... by Ben Clayton <bclayton@google.com>
  - d2170a3da19e5108c717198a4cfd00a94e8b0ec8 [spirv-reader] Add requires for RW textures by James Price <jrprice@google.com>
  - cdcc15311ff58993d66ac4923ff9e259c7ea3c9f [tint] Remove unused include from common options by James Price <jrprice@google.com>
  - 631aaa36b20883f72f2a428e3fe9912d1634ec4f [glsl][hlsl][msl][spirv] Ignore requires directive by James Price <jrprice@google.com>
  - 0840920e4a29384371c9c1624970815d901c0a7c [tint] Handle Requires in SingleEntryPoint by James Price <jrprice@google.com>
  - b51477ba2f34044f5422c9aa40df4519e3b51bed [wgsl] Parse RW storage texture language feature by James Price <jrprice@google.com>
  - bdbeb35882c4a8352c6119b5493c88ead4f7aaea [wgsl][writer] Emit requires directives by James Price <jrprice@google.com>
  - 9b6ba18fcea05507c72b2b8b2994c017f0fb66da [tint][ir] Handle requires directives by James Price <jrprice@google.com>
  - 254e3a9e8ff75b95451b44e8fbddcb828082a6f9 [tint] Resolve requires directives by James Price <jrprice@google.com>
  - 55b671bf57c5f5ea1374411ed793a642221f6bee [tint][wgsl] Add `Requires` AST node by James Price <jrprice@google.com>
  - b926b1f351c73118101c30cf6b7de3dfa7cf6cdd [tint] Add LanguageFeature enum by James Price <jrprice@google.com>
  - 531663f4669bbb466f020b4dd490f6e1dfd3c6b7 Fixup binding generator for duplicate bindings. by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: 558f0dfed76840e3793d2468b3b504d465b8ee89
Change-Id: Icfed6d99331e4941506913d87b1f492c07c86120
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/159140
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
70 files changed
tree: e5d4b74636027b238578f77827a225ed49412c25
  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
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.