Import Tint changes from Dawn

Includes manual roll of various DEPS.

Changes: - 0acbb4e047c02713311472a262bf422bcc892791 Remove if-break deprecation by dan sinclair <dsinclair@chromium.org>
  - 669e15e1390960b58a705fa2116c36c868730ef3 [ir] Add EmitBinary by dan sinclair <dsinclair@chromium.org>
  - f6fcf0a3ef949a9d0beffc4457ae4a0daebb932d [ir] Add conditions to if and switch nodes. by dan sinclair <dsinclair@chromium.org>
  - a8bc2962598a16b369840059425754da3c530522 [spirv-reader] Emit break-if as needed. by dan sinclair <dsinclair@chromium.org>
  - a5b73a0fde4848aea9d9724e75d62f868a5153e2 [ir] Implement EmitLiteral. by dan sinclair <dsinclair@chromium.org>
  - 329dfd7cbd2df6025c697e3f00acbf91f65bd0fd tint: Implement const-eval of modf by Ben Clayton <bclayton@google.com>
  - 92d858ac3c497743921251a3b698803aee6ff0c1 tint: const eval of length builtin by Antonio Maiorano <amaiorano@google.com>
  - c982cd45c48304fae850725feaeec4689dd68157 Use TINT_REFLECT for OverrideId by Austin Eng <enga@chromium.org>
  - f9c6633006e84f697996fb72e570114576cc32c3 Update inter stage variable subsetting validation and add... by shrekshao <shrekshao@google.com>
  - 7f760cb25c36c99d09067a4b8022e91057fcf20f Tint truncate interstage variable transform by shrekshao <shrekshao@google.com>
  - 840bf6fc6d2d7c809c845c29e8e4cb26fb97bc1e [ir] Add a Register class. by dan sinclair <dsinclair@chromium.org>
  - 2664229fd5673b311b70ec9764e6435681e91fac Cleanup some grammar. by dan sinclair <dsinclair@chromium.org>
  - 6559903234da5967dd4ac06b545a9e81dab91dbf tint/resolver: Split constant checking to utility by Ben Clayton <bclayton@google.com>
  - d6d30f425653576f9a3da43f462a55327323b30f tint: const eval of dot builtin by Antonio Maiorano <amaiorano@google.com>
  - b2e6b7b8654fb1288c888f6d20fd9a9011b84e1f tint/resolver: Consistently use ConstEval::Result by Ben Clayton <bclayton@google.com>
  - e02377c2b383f1d11b115dc4fc128a5161810b07 [ir] Testing updates. by dan sinclair <dsinclair@chromium.org>
  - 51ecf65d437d0b754b4a0d50b1507c611846bc70 [ir] Stub remaining AST walk structure. by dan sinclair <dsinclair@chromium.org>
  - a32b6b4a0f4f02946072f66808728dda29533c81 [spirv-reader] Remove `forced` param from `MakeBranchDeta... by dan sinclair <dsinclair@chromium.org>
  - 81ce4b6237260ccb598b5d5b03d2a875b8e235f4 tint/transform: Include diagnostics in TINT_PRINT_PROGRAM... by Ben Clayton <bclayton@google.com>
  - 87bccb74d8a885cd1e6cc1dc52b4c003254859fc tint/transform: Handle arrays of complex override lengths by Ben Clayton <bclayton@google.com>
  - efe9c49819a61ba2d43ba6618bd043380e5a97f9 Add const-eval for `degrees` and `radians` by dan sinclair <dsinclair@chromium.org>
  - 619f9bd639aec0df39163f5440a835370930ea7e tint/transform: Fix ICE when combining polyfills by Ben Clayton <bclayton@google.com>
  - f5eec817de0df46d5aa2a7205f5b2f9c02e98dd4 tint: enable smoothstep error tests for f32 and f16 by Antonio Maiorano <amaiorano@google.com>
  - 1eaeb310a76a294fcc795eb5f6a7bed5723dd4dd tint: fail on creation of a non-finite constant by Antonio Maiorano <amaiorano@google.com>
  - 72551392e8871cb169e6ea74674bb840abb4bfca tint: remove ConstEval::current_source member and pass do... by Antonio Maiorano <amaiorano@google.com>
  - 893316014a3dc680226869196dc6bd0a7362c079 tint: emit an error for float conversions that are not re... by Antonio Maiorano <amaiorano@google.com>
  - fcac2f83040eb24461727eeefa1d487186cbffd8 tint: Strip aliases that reference unused overrides by James Price <jrprice@google.com>
  - 542db5ce066151564bba89d85ad08c8a196e1bcd tint: Fix TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM by Ben Clayton <bclayton@google.com>
  - 0d2aedf097a4c3732dff03fc901dfd73da909968 Run ./tools/format by Ben Clayton <bclayton@google.com>
  - 543dd18d3c517fa80f9fca3523c133a301e0032a tint: Remove textureSampleLevel(texture_external) by Ben Clayton <bclayton@google.com>
  - aedda6a50076c7747e66954a1b55bc0776615d17 tint: remove all inf/nan input cases for const-eval built... by Antonio Maiorano <amaiorano@google.com>
  - aff1656a762cb303715a3be72e58911df5c6a0f4 tint/spriv-reader: emit error on non-finite literal by Antonio Maiorano <amaiorano@google.com>
  - 0da91e06c57a9e45056c1690b972596f44fe7570 tint: make const eval of binary ops on concrete values fa... by Antonio Maiorano <amaiorano@google.com>
  - 9e15952e2d1af7fc7e910ffdc8352b76ac497b87 tint: Fix set of overrides in the shader interface by James Price <jrprice@google.com>
  - 83cef52eb74e208e9073de449f997a014ce45261 tint/resolver: Error when quantizeToF16 value is unrepres... by Ben Clayton <bclayton@google.com>
  - c2e2013c2d37d685776e4302bf7827194eca58c6 tint/resolver: Fix DBZ with explicit strides of invalid a... by Ben Clayton <bclayton@google.com>
  - e412c8d8c6adf0491ac03fa4f9d5eb268cbfa93d Remove tint::Source::data_view by Ben Clayton <bclayton@google.com>
  - 6a4c918cbfc6ea6c2ea0dc377851adb32d929cfd [ir] Sketch out tree walk by dan sinclair <dsinclair@chromium.org>
  - 5fbce71eeacd18295db28881352721eeee5cb875 Change some kNone to kUnknown. by dan sinclair <dsinclair@chromium.org>
  - 4d65fc91bb284269dd723fadb8ecead1eb28696c tint: Implement pointer alias analysis by James Price <jrprice@google.com>
  - d6f9a8a25305a2da47f0fc1d53bdff4ee8b01496 Enable some disabled test. by dan sinclair <dsinclair@chromium.org>
  - 46682e7e6bcd3819d35bee7477061cdaeb0a383f tint: remove redundant insertBits tests by Antonio Maiorano <amaiorano@google.com>
  - 8fbfacfd433fc368dad5c658deec31b9b43005e8 tint: fix insertBits edge case by Antonio Maiorano <amaiorano@google.com>
  - 32c28cbc9047e15bef4aac05b2662bf43e698588 Add const-eval for `smoothstep` by dan sinclair <dsinclair@chromium.org>
  - 19e5042adea7ee1d2e0e20fdbb37c5c74c7179bc Add const-eval for `round` by dan sinclair <dsinclair@chromium.org>
  - c214cbe98bf95d146d4108221036b5527ea14436 Add a `none` format. by dan sinclair <dsinclair@chromium.org>
  - 4d89ce1a680162f2239b6d934c4de416a27962f6 tint/number: add Checked* overloads for f32 and f16 by Antonio Maiorano <amaiorano@google.com>
  - 6be02b607f127b15ab57f35e95491ff253902837 tint: Fix stability of intrinsic_table.inl by Ben Clayton <bclayton@google.com>
  - 2d90dedea415dc1032db77d044573a0b49adbb40 Add const-eval for `sqrt` by dan sinclair <dsinclair@chromium.org>
  - 92af2b56935e3ba774a9499c5065d11e5a053b43 Add const-eval for `trunc` by dan sinclair <dsinclair@chromium.org>
  - c6d46994af9cf10d3d0ea50556cff12ab725ab5a [ir] Add framework to dump IR to text by dan sinclair <dsinclair@chromium.org>
  - acce83d10975dd9c6ef0137ba11198a22754034a Add const-eval for `min` and `max` by dan sinclair <dsinclair@chromium.org>
  - 7f06aa06ac1ce14195bf99ea46bdcbc322cd6927 spirv-reader: support NumWorkgroups by David Neto <dneto@google.com>
  - 267f1748c8287ee6ef27ed0bf65a7ede9f8afc31 Remove infrastructure for fallthrough by dan sinclair <dsinclair@chromium.org>
  - bf586f6dfd24ed223881961f47501c1200e3b6dc Remove fallthrough from WGSL parser. by dan sinclair <dsinclair@chromium.org>
  - d8a986beaebd705568608be3eb2aba1127d5f833 Remove fallthrough support from SPIRV-Reader. by dan sinclair <dsinclair@chromium.org>
  - 3c32758a0e6dbedfd08b731addee74aad5f4eb67 spirv-reader: Support texture and sampler args to user-de... by David Neto <dneto@google.com>
  - 1db8831be4c9c03d6fb1111014214bdfdfefe98b tint: fold error cases into regular case in const eval bi... by Antonio Maiorano <amaiorano@google.com>
  - 208fc35471c35da87b6cb0118fb43c52f629ac8a spirv-reader: refactor getting handle type by David Neto <dneto@google.com>
  - 8cd34f8425e4c7e94e786c2f2a15ff50f8b19760 tint: Fix DemoteToHelper for atomicCmpXchgWeak by James Price <jrprice@google.com>
  - 10fae7ac79e1bcb543efb41188196364f2722106 tint: Rename `frexp().sig` to `frexp().fract` by Ben Clayton <bclayton@google.com>
  - 1ef277db0ede0e4834e753ffcea829bcf8e20781 tint: Skip e2e test validation for known-good by Ben Clayton <bclayton@google.com>
  - c33d10ae79e5a9aa99512a7736da93039824f53b tint/resolver: Fix bad pointer deref (UAF) by Ben Clayton <bclayton@google.com>
  - 4e0eac148d622dd2d7d39937157a3e33a67fc264 Manual Roll third_party/vulkan-deps/ a7a3fb393..c29c532c9... by Ryan Harrison <rharrison@chromium.org>
  - 183b8eb19c87ca468edd7bbf6efe1dc62610b47c spirv-reader: func decl with handle or ptr-to-handle by David Neto <dneto@google.com>
  - b77332edd22fea10a6e145788bf54e9fa289341b Add const-eval for `tan` and `tanh` by dan sinclair <dsinclair@chromium.org>
  - 02d4ea06b9ad4ed7d48664c9518e7241c9425a39 Add const-eval for `cos` and `cosh` by dan sinclair <dsinclair@chromium.org>
  - b7868ff3ee24af868eadc9ee4d089372544dc4c1 Add const-eval for `sin` and `sinh` by dan sinclair <dsinclair@chromium.org>
  - e2fd5e09c6a938a2814906e0ed8ae5a9615fff9e Implement const-eval for `acosh` by dan sinclair <dsinclair@chromium.org>
  - 46ee63933c1e8c395d5dd5e6e284bc830f97f39a tint/transform: Implement div / mod polyfill by Ben Clayton <bclayton@google.com>
  - 9418152d08ec3efef9d62af290359a03c9cfa1db tint/resolver: Move from STL to tint::utils containers by Ben Clayton <bclayton@google.com>
  - 55a8eace750acd7155becfe9f1b240ef93d3bb58 tint/resolver: Forbid workgroup pointer parameters by Ben Clayton <bclayton@google.com>
  - 5ac2a365d90f649f5df8231e9745219997ee2812 Add const-eval for pack and unpack of 2x16float. by dan sinclair <dsinclair@chromium.org>
  - 00d0fd5e840d70d95b254631ef78045fa4220990 Update f16 to have from_bits by dan sinclair <dsinclair@chromium.org>
  - 744d0eb4aace2a6b110ce454152a27cc9f93d2d5 tint: Use "demote-to-helper" semantics for discard by James Price <jrprice@google.com>
  - 78ae4c243b6b99aee36661b1bf4c20be38122c1b tint: Fix phony assignments in DemoteToHelper by James Price <jrprice@google.com>
  - 97519c2cd3c4616966c56382f1895d99d230fc5f tint: Allow captured pointers as function args by James Price <jrprice@google.com>
  - 6251598ad2954427c352c7c36db7af27934cdc9c tint: Add DemoteToHelper transform by James Price <jrprice@google.com>
  - a7cd3aeff08d734a79259dba47066076d5379c42 tint: Rename SourceVariable() to RootIdentifier() by James Price <jrprice@google.com>
GitOrigin-RevId: 0acbb4e047c02713311472a262bf422bcc892791
Change-Id: Iae43e7c286bbf91f79457cd850d17f5cd683ad18
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/111501
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
169 files changed
tree: 34e2c5e596bc2ae94c7cb8a99db773073700a6ff
  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.