Import Tint changes from Dawn

Changes:
  - 8ef731141397bc0d4a2d474ffbdd55c417ca860f tint: validate max number of members in a struct by Antonio Maiorano <amaiorano@google.com>
  - 8cd5c611fcc7d78c4871443128a1b18597443737 tint/reader/wgsl: Remove element_count_expression() by Ben Clayton <bclayton@google.com>
  - dec0c62997bc037bc6a88be39a6939d5a479bf1b tint: optimize SymbolTable::New by Antonio Maiorano <amaiorano@google.com>
  - 66d487395d293c983bde13e14709df6eb2bb01e4 tint: Use PI/2 as the input value for sin tests by James Price <jrprice@google.com>
  - 1a1b5278d5f807cb8e510df541913c8d223aa833 tint/transform: Inline HLSL uniform / storage buffers by Ben Clayton <bclayton@google.com>
  - 7052cb57ff6b5463531640c386ae0798ed4f225f Revert "Add test setting the locale." by Ben Clayton <bclayton@google.com>
  - 65a45fdf419d77a470c18a344126d2299632db82 Handle errors in SPIRV-Reader tests. by dan sinclair <dsinclair@chromium.org>
  - 107aa81c891a5a5938375d7bdbae028b579ebfd6 tint: Improve error for assignment to immutable variable by Ben Clayton <bclayton@google.com>
  - 9cdc3343ff2f88e44bbc2f43feb2c0f05b3e03ad Add test setting the locale. by dan sinclair <dsinclair@chromium.org>
  - 077d97a387bf41700fadccbc2b95df24162682b8 Add `SuggestAlternatives` to attributes. by dan sinclair <dsinclair@chromium.org>
  - 9386f73446d8aa997a213c0ed910d923cfcf032a tint: Fix compilation error with latest MSVC 17.5.0 by Antonio Maiorano <amaiorano@google.com>
  - 869bcabf88bc521ef209f9f9f1c6a5449c1478cd Make attribute grammar generic. by dan sinclair <dsinclair@chromium.org>
  - 39b7330b5b509e7c4111faf17f6f489d719bc319 Fix UV coord for TextureLoad by jchen10 <jie.a.chen@intel.com>
  - 9776edf161586a7686bab13d9aa03a62c1d11204 tint: Improve error message for array element stride in u... by Antonio Maiorano <amaiorano@google.com>
  - 187e0d5fe78c5996e93d5bb2981e2b16a88291db Add `requires` directive by dan sinclair <dsinclair@chromium.org>
  - 54a104e28f4a8d86c80dd9e0905d54e34009cc0a tint: Update constructor / conversion terminology by Ben Clayton <bclayton@google.com>
  - afc53fa942b86e219620ec67ae4f9a268c0918e8 tint/resolver: Bring back enum suggestions by Ben Clayton <bclayton@google.com>
  - b549b3051e3c04350d428527fc9b3e015d1b44a2 tint: Validate @must_use on functions and builtins by Ben Clayton <bclayton@google.com>
  - d84903201db21eb69d28a80b65297cff9d826fc6 tools: Add @must_use support to intrinsics.def by Ben Clayton <bclayton@google.com>
  - ce10962d82e43f65de0f2be56a617b9b9376f812 Add parsing and emission of the `must_use` attribute. by dan sinclair <dsinclair@chromium.org>
  - 5662f79b24f031f8350f2f3811d2940df2ab0dfc tint/ast: Remove unnecessary ast:: prefixes by Ben Clayton <bclayton@google.com>
  - 239b4298b3673e92c3ca8c96ad6e858431ad9181 tint/HoistToDeclBefore: Use explicit types by James Price <jrprice@google.com>
  - 60d373810230b1cc6246122e1c63ab0eccb8bbf5 tint: Fix ICE in ast::TemplatedIdentifier ctor by Ben Clayton <bclayton@google.com>
  - 2f689a7efe70d0ca86b195a04cc6bdaceb84e5cf Remove deprecated inspector fields. by dan sinclair <dsinclair@chromium.org>
  - fdef03321033af75c363d7f40ab33ada91c965bb tint/resolver: Fix ICE in ResolvedIdentifier::String() by Ben Clayton <bclayton@google.com>
  - f0b4dbb82dcde3e9ea152a459a5865bc3d93b3dc tint: Resolve @interpolate() args as expressions by Ben Clayton <bclayton@google.com>
  - a79c6603b2e787a0da8ef1e517eda4522baa5f09 Add `@must_use` AST node. by dan sinclair <dsinclair@chromium.org>
  - b92ff397245c97989e8efbb723dfea9f2719185c Remove `static_assert` deprecation. by dan sinclair <dsinclair@chromium.org>
  - 4d3ff9711e55d049ec4d1979db49eaa74fa4a3b8 tint: Resolve @builtin() args as expressions by Ben Clayton <bclayton@google.com>
  - 21571709a2f6ef64596956b78762f35bdc96ccc0 Remove the `type` keyword. by dan sinclair <dsinclair@chromium.org>
  - 2d6f90771b4745441e281aee5d40d4148a508bfc tint/reader/spirv: Remove stdout spam by Ben Clayton <bclayton@google.com>
  - 993a658af2a40bc9ac9c3db42bb26f0b3736cf04 Move InterpolationSampling and InterpolationType to built... by dan sinclair <dsinclair@chromium.org>
  - b5af23d5880d0f2f5ecb3517bc8a92b685c778c4 Move diagnostic severity and rule to builtin. by dan sinclair <dsinclair@chromium.org>
  - ef30aa400c104445c2d81f50ec37c359a41538e9 Move type/builtin to builtin. by dan sinclair <dsinclair@chromium.org>
  - ba082fdb48fab870d11acc9e60eaf6afe76aa180 Move TexelFormat to builtin by dan sinclair <dsinclair@chromium.org>
  - 2a65163c6d4843e417bf60e9aa282eeb5e89bc04 Move type::AddressSpace to builtin/ by dan sinclair <dsinclair@chromium.org>
  - b6cc4cbf896855201079030d28feb2070e020e54 Move type/access to builtin. by dan sinclair <dsinclair@chromium.org>
  - 79781f26d1fc525fb9c3ba291e5660ea3da6eeb1 tint: Unkeyword 'var' template args by Ben Clayton <bclayton@google.com>
  - 1b90f937422b1526245f3224194a99c0ed5ee5bc tint: Remove type::AddressSpace::kNone by Ben Clayton <bclayton@google.com>
GitOrigin-RevId: 8ef731141397bc0d4a2d474ffbdd55c417ca860f
Change-Id: I86c586f9f089f2c8e2a0cf07d809b85ec5d3a16b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/120523
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
490 files changed
tree: 15a38981dd02cf79e9e1079fef750fcbdc8d8487
  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.