Import Tint changes from Dawn

Changes:
  - fafeb9a3279b602f59cc7493bb15fe1931fefaee tint/reader/wgsl: Improve errors when parsing access cont... by Ben Clayton <bclayton@google.com>
  - bccd87c37a90dca50e82f31a2eb1f055398db656 tint/ast: Generate access.[h|cc] by Ben Clayton <bclayton@google.com>
  - a44e3d8bea3f4e4430c04b20695ff0812ac32a52 tint: include T type in converter overload diagnostics by Ben Clayton <bclayton@google.com>
  - c889500f6e3e8fa5c23c8235848a2a06a2f5fa31 tint/reader/wgsl: Improve errors when parsing interpolati... by Ben Clayton <bclayton@google.com>
  - 542d27d874fb558614f229886e083f9a3119dea2 spirv-reader: support GLSL.std.450 instruction FindILsb by David Neto <dneto@google.com>
  - 2ad747dedd99d4f88742295f2760ae35759b2dd9 tint: Fix const eval unary tests by Antonio Maiorano <amaiorano@google.com>
  - 75bc93c0df83671adc3a62c172bd33a8be939dad tint: Fix const eval of type conversions by Ben Clayton <bclayton@google.com>
  - feb447d9dc271b94017a0ee41ff6ef7f97276cc3 tint/resolver: Formatting by Ben Clayton <bclayton@google.com>
  - f9ed9d3a6349f781957fccae7af9bf8d6bd268b4 tint/ast: Generate interpolate_attribute.[h|cc] by Ben Clayton <bclayton@google.com>
  - c1af0f5005d04d2db500acba0f093cafe9a95de5 tint/reader/wgsl: Improve errors when parsing address spa... by Ben Clayton <bclayton@google.com>
  - 9af5b406bab262d713338f350d3a8544cf762c8d tint/reader/wgsl: Improve errors when parsing texel formats by Ben Clayton <bclayton@google.com>
  - ecd7f7ee7fbbf438ff05a0b0ced26983e13fa6f6 tint/reader/wgsl: Improve errors when parsing extensions by Ben Clayton <bclayton@google.com>
  - 760eee9e925141186b0e76357dcb08d3d010ebfc tint/reader/wgsl: Improve errors when parsing builtin by Ben Clayton <bclayton@google.com>
  - b7aef033fa73937cbc837478d9244999df26257d tint/templates: Generate enum string arrays by Ben Clayton <bclayton@google.com>
  - 3e0984afe036c85238cd61e647ccf892894b88d0 tint/program_builder.h: Remove stale comment by Ben Clayton <bclayton@google.com>
  - db368f1b9c310873f1194a18deac890f44de81b3 tools/tint/intrinsic: Sort enum values lexicographically by Ben Clayton <bclayton@google.com>
  - ae832a2c6ae769593321ae5f8368c948f4727376 tint/reader/wgsl: Minor cleanups by Ben Clayton <bclayton@google.com>
  - d04c54e1784c6cafa5c8b3a936c1c682f99de4e4 tint/utils: Add Levenshtein Distance() function by Ben Clayton <bclayton@google.com>
  - 3c34d83088f6e90294f63d1191b04d2f1d70429a tint/ast: Add missing 'const' on pointer member by Ben Clayton <bclayton@google.com>
  - ab2fa8be87f3cc7a636230b07d61b96f2d9c7d30 tint: Fix vector equality operator by Ben Clayton <bclayton@google.com>
  - 8d3d4f6fd11fb179b4c56b782e9e5ef0da1fd4a9 tint/inspector: Reflect whether @builtin(frag_depth) is u... by Corentin Wallez <cwallez@chromium.org>
  - 98a7cd11aff1850f953f26fb6db6dc06632b8d63 Add a ClampFragDepth transform. by Corentin Wallez <cwallez@chromium.org>
  - 5cbb32d764fb93c7586fb01b48a20fca32b6682b Tint/tranfsorm/test: Refactor and add exhaustive test for... by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - 112d7614483a266869cb74891a8bdb9c5b5bb1ee spirv-reader: Track storage class for pointer/ref values by David Neto <dneto@google.com>
GitOrigin-RevId: fafeb9a3279b602f59cc7493bb15fe1931fefaee
Change-Id: I00adc0bca37895f36e239a67b32b04270f606e4a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/105380
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Copybara Prod <copybara-worker-blackhole@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
89 files changed
tree: ffa3b7bd7f153103cf53f13d1f0cd4853f197948
  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.