Import Tint changes from Dawn

Changes:
  - 183df9d24ef84d2e36b11cd5ae35796e81ad5dc5 Implement External Texture Crop Functionality by Brandon Jones <brandon1.jones@intel.com>
  - 02b466feb1897b6a6a1f6c44bf9f156411331b0e Move CreateComposite into ProgramBuilder. by dan sinclair <dsinclair@chromium.org>
  - 19ebcb22308a7b158a3237f10e46cc48a45352e8 Convert ir::Constant over to use a constant::Value by dan sinclair <dsinclair@chromium.org>
  - dd1e4e39f23dfd0f6e40729a78538f92573d0b44 Fix typo by David Neto <dneto@google.com>
  - b53b8cf5be9003d42b7961edf990714f8102d3fc Rename constant::Constant to constant::Value. by dan sinclair <dsinclair@chromium.org>
  - ea1cc79cb86050aa373ab322fb7b94b8218e7202 tint/castable: Add Maybe() MaybeAnyOf() by Ben Clayton <bclayton@google.com>
  - 5addefb1488d4896f9eb3eef6ddd106d10ff7c84 Rename Constant::As to Constant::ValueAs. by dan sinclair <dsinclair@chromium.org>
  - 35842190efb229c3054abf5918c2953da5ea9ecb tint/castable: Reformat comments (grow width) by Ben Clayton <bclayton@google.com>
  - 93c0ef2b3309b737730cc0624d48809eb630e7ed Reduce default vec size in composite. by dan sinclair <dsinclair@chromium.org>
  - 9268561678405405013d562ac1e2f31f9eb2c223 Remove ImplResult. by dan sinclair <dsinclair@chromium.org>
  - 8626c9ee87e96f7c3d5a0b63276d1670b51159ef Move constants into constant namespace. by dan sinclair <dsinclair@chromium.org>
  - 0890380d10112b6071922dcb8af7166f8386bdd3 Split concrete constant classes into own files. by dan sinclair <dsinclair@chromium.org>
  - 7efe4860c97b491c8bb2480ca4fcff3f8372cab9 Move helper methods inside Scalar. by dan sinclair <dsinclair@chromium.org>
  - 5225fcc689731cd207aa9fce0e864710305bb72e Remove ImplConstant. by dan sinclair <dsinclair@chromium.org>
  - d586d914780ba28ebb3ff93547262dbb73c8c0de Extract constant convert methods. by dan sinclair <dsinclair@chromium.org>
  - 2e737daaae7f13298b7b4497f373c0c8bff820ee Rename Element to Shader in ConstEval. by dan sinclair <dsinclair@chromium.org>
  - 0335c7d65ddab8f14ad24455d23090e80e8f0d13 tint: Add matrix short names by Ben Clayton <bclayton@google.com>
  - 167a7da051df11c4e16035b56b0ceefc8d069752 tint: Add TypeInfo as a field instead of a virtual by Ben Clayton <bclayton@google.com>
  - 188ed1793a20602bba04792f4e7b426f329bff4a tint/resolver: Correctly validate f16 usage by Ben Clayton <bclayton@google.com>
GitOrigin-RevId: 183df9d24ef84d2e36b11cd5ae35796e81ad5dc5
Change-Id: I787666d168c03e35afeffd60c290ebc61e1933c8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/114460
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
92 files changed
tree: f470d3d25c11101fed7119fab7b1f733e0402d1a
  1. .vscode/
  2. build_overrides/
  3. docs/
  4. include/
  5. infra/
  6. kokoro/
  7. src/
  8. third_party/
  9. tools/
  10. .clang-format
  11. .gitignore
  12. .gn
  13. AUTHORS
  14. BUILD.gn
  15. CMakeLists.txt
  16. CMakeSettings.json
  17. CODE_OF_CONDUCT.md
  18. CPPLINT.cfg
  19. DEPS
  20. Doxyfile
  21. LICENSE
  22. OWNERS
  23. PRESUBMIT.py
  24. README.md
  25. standalone.gclient
  26. 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.