Import Tint changes from Dawn

Changes:
  - 55c0c9d950edb4f45b2f94d5c3e4114fc30609e8 tint: Add abstract numerics to vector and matrix construc... by Ben Clayton <bclayton@google.com>
  - d3de38d7e3880a90cbed8f8fb895729e580c8fbd tint: Simplify the resolver constant evaluation by Ben Clayton <bclayton@google.com>
  - 8f4f4495408cfde7755be8127180178015bf7d40 tint/writer: Do not attempt to use invalid programs by Ben Clayton <bclayton@google.com>
  - 6522837acbf96682583ada4ead5c8e86f28df437 tint: Add `enable_abstract_numerics` flag on Resolver by Ben Clayton <bclayton@google.com>
  - 43581f1fb62ced507e1693c2e8959ed342dd7f6a tint: Add new methods to semantic Switch nodes by Ben Clayton <bclayton@google.com>
  - a2ce4ecc8b325ff79176a867b6074b6ca733851b tint: Add more helpers to resolver_test_helper.h by Ben Clayton <bclayton@google.com>
  - d99af036634c3dc612d18042465bfcc45203fffc tint: Add utils::UniqueVector::data() by Ben Clayton <bclayton@google.com>
  - ab4c0357629178ec2c217b4b05ad715142546fe1 tint: fix HLSL countOneBits and reverseBits for i32 args by Antonio Maiorano <amaiorano@google.com>
  - e9ce8326b7843be34e8a31a5a54600cb924c83f2 tint: Minor, miscellaneous cleanups by Ben Clayton <bclayton@google.com>
  - eee9f88ba21b182d7eb23bbc85af17f69185e34a tint: Extract intrinsic-table common type to helper by Ben Clayton <bclayton@google.com>
  - 1b35e3f9a8c10c11d750fde76f0862e8e9bc9534 tint: Add new sem::Type helpers by Ben Clayton <bclayton@google.com>
  - e5a67ac891a5c8aa584b7998d35453a29b778a93 tint: Remove ast::CallExpression -> sem::Call implicit ma... by Ben Clayton <bclayton@google.com>
  - 7b921fb4c778b324d706f78a91d5e047626f2292 tint: No-op Resolver refactoring by Ben Clayton <bclayton@google.com>
  - 86a617f1108cbfa49c8c1faebc7b4af8acd36588 Add InsertBraces: true to .clang-format by Austin Eng <enga@chromium.org>
  - 2081ee43bf51005e2dbed2b271254d517e998fd0 tint: Add sem::Materialize by Ben Clayton <bclayton@google.com>
  - 6ac00ed0c0cff0401da91b4faad649d0ea81f2d5 tint: IntrinsicTable: Add abstract numeric types by Ben Clayton <bclayton@google.com>
  - b1fa457ab3c362a12bd885254352fc617d89f808 tint: IntrinsicTable: Use [[display]] name for type match... by Ben Clayton <bclayton@google.com>
  - b0664684cd887f8c8163e70b64c797852b86e276 tint: Support tuples in utils::Hash(). by Ben Clayton <bclayton@google.com>
  - 7f2b8cd8fc8edf464602ea64d2145def40fa3475 tint: Refactor Extensions / Enables. by Ben Clayton <bclayton@google.com>
  - 23696b1ba3fd523f9f989677890af18db0d68d7a tint: Implement abstract-numeric overload resolution by Ben Clayton <bclayton@google.com>
  - 2e681052b313ed547189d95d58d73081c028d604 tint: Fix use-after-free by Antonio Maiorano <amaiorano@google.com>
  - c670018aea9f3ff989699b47c0b5d5a977213cc8 tint: intrinsics.def Support [[precedence]] decoration by Ben Clayton <bclayton@google.com>
  - 5ff7d67bf341af630c8945296155b77edc13ef81 tint: Validate that sampled texture type must be f32, i32... by Antonio Maiorano <amaiorano@google.com>
  - e0ff664a7f0dee5ac9c3c19e48121b6cfca89c31 tint: Add sem::Type::ConversionRank() by Ben Clayton <bclayton@google.com>
  - 4c9ed74b5e5bded47aa034026a6ea80b27dd666b tint: IntrinsicTable: Rename open/closed -> template by Ben Clayton <bclayton@google.com>
  - aaa9ba30436bdb23a59b9eaa4e65f1808cba0dec tint: Simplify sem::Constant::Scalar by Ben Clayton <bclayton@google.com>
  - 661e33ca185f766019bd27fedda57a354efed787 tint: Cleanup of IntrinsicTable by Ben Clayton <bclayton@google.com>
  - 8ba6e1d6ecdd3f9438b5034d32b301152cb931f8 tint: limit expression depth to avoid stack overflow in b... by Antonio Maiorano <amaiorano@google.com>
  - 5880ed164abb36f816bbea1a715ad7bc988c3648 tint: Fix edge for CallSiteRequiredToBeUniform by James Price <jrprice@google.com>
  - 3b5edf143505f6b97f065e83de0d63f647fd3e50 tint: Add matrix identify and single-scalar ctors by Ben Clayton <bclayton@google.com>
  - 6ae608cb03840d1f8b075289f4445f149ab33f0a tint: Add constructors and conversions to the intrinsic t... by Ben Clayton <bclayton@google.com>
  - 9ff8abf34711e4e740b68c10fc0c90bbc441c7e5 tint: Fix clang chromium-style warnings treated as errors by Ben Clayton <bclayton@google.com>
  - e6b6777c8e56b0940315b9fef97a13e021c61747 tint: Fix MSL generation of '&' and '|' with booleans by Ben Clayton <bclayton@google.com>
  - 35f0fcaac0f6e0d0a56e8f5f7c00cd297256d518 tint/uniformity: Use non-recursive graph traversal by James Price <jrprice@google.com>
  - a89ff5981bc0c17e980a5dbdb4f2da870ed79db0 tint: Show where control flow became non-uniform by James Price <jrprice@google.com>
  - 1c75921db9c0095d7ab96c686f51efa2951b2f4f tint: fix translation of DP4a on HLSL by Jiawei Shao <jiawei.shao@intel.com>
  - d8e77e2e73afd5bb2238ac322d7acbdd084ec410 tint: Prevent integer overflow in IntrinsicTable by Ben Clayton <bclayton@google.com>
  - 83fc247d4bb9ab23616a697f272d69f29f44447f tint: correctly define user-defined literals by Antonio Maiorano <amaiorano@google.com>
  - 59e23943f3b1442281208e879e6bc4c5f478ca91 tint: Minor IntrinsicTable cleanup by Ben Clayton <bclayton@google.com>
  - 77473b469958b242509c9eb9271bbcf908e791de tint: Split tables for unary and binary operators by Ben Clayton <bclayton@google.com>
  - 62bfd318aefae4b5a1f50813f90bf0b8b821849b tint: Implement `f16` keyword in Tint frontend by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - c4b380b8af94fe8b7a61ae8bd3f735f9d7a51380 tint: Generalize sem::Vector to allow 16bits subtype by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - ed6ff9c948005a23fb2d592c5ea069d778bca083 tint: Rename kNotAnExtenxion to kNoExtension by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - ab9757036bd6b2fe86c4e937db0524463ba0c0f8 tint: Implement DP4a on HLSL writer by Jiawei Shao <jiawei.shao@intel.com>
  - 53547db1d4f045d93ee408b6a30da25eb88ef056 tint: Add missing source information for | and || by James Price <jrprice@google.com>
  - 816148fe3291d3def83de76584cfe32af8572f49 tint: Add implicit CF_return->{last cf} edge by James Price <jrprice@google.com>
  - cd55f15c98de761c6410e19670398c149aa96dbe tint/resolver: Fix chromium-style warning treated as error by Ben Clayton <bclayton@google.com>
  - 7dd0ab791a59c89b628981f82f56b9ee3e8208b6 tint: Show the source of non-uniformity by James Price <jrprice@google.com>
  - 9c03abfb554fd64adb66a9f11d7e84766cdc15b3 tint: Show the reason for a uniformity requirement by James Price <jrprice@google.com>
  - 874b61f1badfe275c480d1dcb6d32b867391de73 tint/uniformity: Retain control flow graphs by James Price <jrprice@google.com>
  - be656f7984a48e3c4e9a3c9dcc0ba7bbdc3da278 tint: Implement uniformity analaysis by James Price <jrprice@google.com>
  - 8e68f0aad7c3994ddbd1914a48d82c43dd6e7e56 tint: Resolve empty loop continuing blocks by James Price <jrprice@google.com>
  - 2cf32b13d7c294a7a3b4e87f9ab11aebbb519e81 tint: Make ScopeStack key type generic by James Price <jrprice@google.com>
  - 791b4351d1860e1d447f182619e8bd1023dc47eb tint: Add transform to disable uniformity analysis by James Price <jrprice@google.com>
GitOrigin-RevId: 55c0c9d950edb4f45b2f94d5c3e4114fc30609e8
Change-Id: I584598c20d24d8cadb29f63b5e1f46aac06aebb2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/89880
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
147 files changed
tree: d4cc7f3ffd8e09f8f58423b4d6f07b543eeb096a
  1. .vscode/
  2. build_overrides/
  3. docs/
  4. include/
  5. infra/
  6. kokoro/
  7. src/
  8. test/
  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.