Import Tint changes from Dawn

Changes:
  - 5c5f47afbf4deb6bc6e9f2e38b0206edc4ee2c12 Fixup shadow variable. by dan sinclair <dsinclair@chromium.org>
  - 3f24fdc4476023b30a3a00793391a70bac0379db tint/fuzzers: Don't run the inspector on invalid programs by Ben Clayton <bclayton@google.com>
  - a3175f28f6d80e826eebe399b6b53430df6de6f2 tint: const eval of firstTrailingBit by Antonio Maiorano <amaiorano@google.com>
  - 1abe52dc1cd5e66d8cf7fee351b4df6ddf3a5259 tint: const eval of firstLeadingBit by Antonio Maiorano <amaiorano@google.com>
  - 76c21c070bc4889437b5538ddb143aba2e759034 tint: const eval of countOneBits by Antonio Maiorano <amaiorano@google.com>
  - 6dbb463f1deff71c0bff1eccaf44a240aab8ace1 tint/writers: Polyfill integer clamp() by Ben Clayton <bclayton@google.com>
  - be83128031408a5f77f4ec26faa22db4f9d450e2 tint/transform: Don't hoist textures / samplers by Ben Clayton <bclayton@google.com>
  - 22c4850b0689a3ec4e1ebcde3c0b9e3ee69f92cc tint/resolver: Allow array sizes to be unnamed override-e... by Ben Clayton <bclayton@google.com>
  - cc85ed6dd1502fe16723378e9e6de317576030e6 tint: Function calls do not affect control flow uniformity by James Price <jrprice@google.com>
  - 3e1bc0a6da82003ef5d15f88c4d3c776a333d23c tint: Use MergeReturn transform in SPIR-V backend by James Price <jrprice@google.com>
  - 8e8e38d1299866688c75074eaf86e93a9e6bc3dd tint/cmd: Expose multiplaner_external_texture transform by Ben Clayton <bclayton@google.com>
  - 116a5e050a1830566195e33170824e1eaaefa13c tint: regenerate intrinsic_table.inl by Ben Clayton <bclayton@google.com>
  - 5de8b436faa84436e2df92b464d84c6672762de5 tint: Add MergeReturn transform by James Price <jrprice@google.com>
  - 8a523d7d8ec5d56822ccf9219cb939cf7bd2881b Add const-eval for `any`. by dan sinclair <dsinclair@chromium.org>
  - 7494e10f912c3856bc15078749ce800f4bd4e1e7 tint: const eval of countTrailingZeros by Antonio Maiorano <amaiorano@google.com>
  - 2be5167e3e099668081110ae9d5bd22b116cd414 tint: const eval of countLeadingZeros by Antonio Maiorano <amaiorano@google.com>
  - 46de10299fafa2c6b4c00c2c6968095d4f761f77 tint/transform/builtin_polyfill: Don't polyfill @const bu... by Ben Clayton <bclayton@google.com>
  - 2048d4f6efa4598bc38e64a2574ee65a50563312 tint: fix identity initializer of vec from vec of abstrac... by Antonio Maiorano <amaiorano@google.com>
  - c395660ee6c6a11aba274e0444d084ede5e40e1b Add const-eval for `sign`. by dan sinclair <dsinclair@chromium.org>
  - fd1b5a893d822c79d1038e688f6e0113c1d3d631 Set specific test value for asin test cases. by dan sinclair <dsinclair@chromium.org>
  - e366dcf747ebe69e54dc42ae99b13f6043375ec4 tint: show template param when printing initializer overl... by Antonio Maiorano <amaiorano@google.com>
  - 71111f8e0d855cf94cc8cc2df6071795ae48b659 Fixup dispatch call for step and saturate. by dan sinclair <dsinclair@chromium.org>
  - eee8d88210633b7d69973ecb2a1517656db5d259 Start adding IR. by dan sinclair <dsinclair@chromium.org>
  - 14b5fb6f1742a8a0ece928a56019e0fd153eb46e tint: add pretty printers for gdb and lldb by Antonio Maiorano <amaiorano@google.com>
  - 91ed6f7289a4a5f070538facc6e3445ad16b2810 Add const-eval for `saturate`. by dan sinclair <dsinclair@chromium.org>
  - c98ad87368ded7b161259d401f0ce8597eaf0f4e Add const-eval for `step`. by dan sinclair <dsinclair@chromium.org>
  - 59d9c89ff71caba6b5efca873e2f96d642713cff Add const-eval for `asin` and `asinh`. by dan sinclair <dsinclair@chromium.org>
  - a92f4259d51ddbc16aef725c82dd23bc2411fe6f tint/writer/msl: Move packed_vector hacks to transform by Ben Clayton <bclayton@google.com>
  - 81ecd739b0933f182fa68d57c360307f693617bb Protect sem::MemberAccessorExpression constructor. by dan sinclair <dsinclair@chromium.org>
  - 2e376a9bb072e5b0bc6590cdc0f2e121f5101a7b tint/intrinsics: Allow mixing of signed / unsigned intege... by Ben Clayton <bclayton@google.com>
  - 13f089095f53fd22a302fd5e69794f8bb5b17d5f tint/intrinsics: Texture queries now return unsigned inte... by Ben Clayton <bclayton@google.com>
  - 0143ec57ba832325db2af86a5c499659032ed3ea Reland "tint::transform::VertexPulling: require SingleEnt... by Corentin Wallez <cwallez@chromium.org>
  - 45844e3df4a435236d281d120d0b01e480057457 Revert "tint::transform::VertexPulling: require SingleEnt... by Dan Sinclair <dsinclair@chromium.org>
  - b3b027d3cddb821a00112aa9cb50fde5c633c337 Update lexer to not include `-` in numbers. by dan sinclair <dsinclair@chromium.org>
  - 63463c2f775fadb56daad93e0e92fe9153a426fd tint::transform::VertexPulling: require SingleEntryPoint by Corentin Wallez <cwallez@chromium.org>
  - 4faf3581b87541c8bdb93c0ae8baaba74ef6c4cf Tint/builder/spirv: Fix atomicCompareExchangeWeak wrong r... by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - 0640c8107304ea0e776df1a09fd3efcf58b2dd2a tint: make uniformity analysis failures warnings again by Antonio Maiorano <amaiorano@google.com>
  - ee42e05101af0c6529ce743b5329d1ab3f9a7f4d tint: enable unit test now that const eval of shift left ... by Antonio Maiorano <amaiorano@google.com>
  - 25fdff1ff8195780fbc9ad418873fb89f4479224 Unrevert "tint: rhs of left shift is always u32 or vector... by Antonio Maiorano <amaiorano@google.com>
  - e0f78f924c7aaffccdee450bfd59d0af6d0a595f tint: always pass in earliest evaluation stage to intrins... by Antonio Maiorano <amaiorano@google.com>
  - 4c8401f33ca13cae92b24af28f4001fd9c7031f8 Add const-eval for `atanh`. by dan sinclair <dsinclair@chromium.org>
  - 5af4d88753bcc0bb0f4a2326321626922fbfe762 tint/resolver: Validate @size only on creation-fixed foot... by Ben Clayton <bclayton@google.com>
  - bd5bd247f0d1c8410c8b622bfbdc68730c7fea7b tint/resolver: Limit scope depth / if-chains. by Ben Clayton <bclayton@google.com>
  - 0423c3ccd09b45fb03b4d77b97f51d695f429f6e Use ConcatIntoIf in const-eval builtin tests. by dan sinclair <dsinclair@chromium.org>
  - f17497cb6dd181327ef220fdcebd36ba069d1d65 tint/sem: Add tests for IsConstructable by Ben Clayton <bclayton@google.com>
  - 95dd428c750d1af73c0b53fa7d12d227a5c134a1 tint/intrinsics.def: Add @test_value() annotation by Ben Clayton <bclayton@google.com>
  - 80b2312493d3a141796b7a770e51a55c2f26747a tint/sem: Add Type::Flags() by Ben Clayton <bclayton@google.com>
  - 434edc2a12dcaaad031a27db5de883fd8297f599 tint/resolver: Allow shadowing of builtins by Ben Clayton <bclayton@google.com>
  - da5424b617cc82946f99005307d7da0e2cf2bfa6 tint: Allow signed / unsigned texture builtin params by Ben Clayton <bclayton@google.com>
  - 20500b8e3a1cd60750176d0e09eb761169bf7542 Add const-eval for `atan`. by dan sinclair <dsinclair@chromium.org>
  - 087c355e0896268bd0e9e7d99eed465539ed8e9c Revert "tint: rhs of left shift is always u32 or vector o... by Antonio Maiorano <amaiorano@google.com>
  - a3325fa94d446f14963985235e08124e950d08b6 Traverse function return attributes. by dan sinclair <dsinclair@chromium.org>
  - cc9ae5cae3558a92e07cf307738d420e600a0757 tint: rhs of left shift is always u32 or vector of u32 by Antonio Maiorano <amaiorano@google.com>
  - 3a1b799585acbadc8c5836caca9c7175535c3119 Review feeback from 106420 by dan sinclair <dsinclair@chromium.org>
  - a7014a969e7de467e14bb0ba9686279deccccc16 Rename primary_expression. by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: 5c5f47afbf4deb6bc6e9f2e38b0206edc4ee2c12
Change-Id: Ic719e2f8dc80e591e1452ca2901f78c054a6f5d1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/108025
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
141 files changed
tree: 8dfb3e0c7f3f2aed74a0dd8411eb4c908e61c7b2
  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.