Import Tint changes from Dawn

Changes:
  - 0ce9ab042ef5896b57833dd73dfa19fc94973b13 tint: Change all ProgramBuilder literals to 'i' or 'u' su... by Ben Clayton <bclayton@google.com>
  - f7357f89a38a95bed97612f417100214a273b23f tint: Castable - support non-default-constructable return... by Ben Clayton <bclayton@google.com>
  - c188ca62ca3ec311cbcf00e96ba0ebd0d7800ebe tint: add --overrides flag to specify pipeline overrides by Antonio Maiorano <amaiorano@google.com>
  - d3921b8230101c802c4fefb9c45a5bab9c503cdc Fixes for C++20 support. by Peter Kasting <pkasting@chromium.org>
  - 7cbd8202e6715ee5d51314bd1e745a5243da82c1 tint: Add Bitcast helper by Ben Clayton <bclayton@google.com>
  - 26cba1cb3925a46e2be60656d2e407e10ce243a1 tint: Fix CFI error in BlockAllocator by Ben Clayton <bclayton@google.com>
  - 06496d4d1a77cc3843fbdaeef1340244c77bd23a tint/reader/spirv: Generate 'i' suffixed literals by Ben Clayton <bclayton@google.com>
  - 8822e2966acf3b7fc0b222af7bad6ef4bcdc597f tint: Merge [S|U]intLiteralExpression by Ben Clayton <bclayton@google.com>
  - f693488bff822ac29a9cd4d0c62a0c94fe745619 tint: Lex three types of integer literal by Ben Clayton <bclayton@google.com>
  - e55877d017ef99cb1edf7301e53df116c1994f85 tint: Chromium-style fixes by Ben Clayton <bclayton@google.com>
  - b3aab0965214e10efea7a5d6fe7e014cb8252a69 AST fuzzer: Change unary expression operator by Author: Shiyu Liu <jamessliu2020@gmail.com>
  - 507a671e7d84fda9a5d34580bcce4eb235f5acf5 tint: Fix indentation in code templates by Ben Clayton <bclayton@google.com>
  - e23283f4974df5b1465f424dde10a5675aba7ab8 tint: Fix `[chromium-style]` auto pointer warnings by Ben Clayton <bclayton@google.com>
  - 4e98fb0bd8c99ac7cc91f7157428f645099b86d3 Factor out code to flatten bindings for msl by Antonio Maiorano <amaiorano@google.com>
  - 8aff0ed684cd140a6dd010b95ceac1decb734f74 tint: Add ProgramBuilder::Else() helper by James Price <jrprice@google.com>
  - 41e4d9a34c1d9dcb2eef3ff39ff9c1f987bfa02a Consistent formatting for Dawn/Tint. by dan sinclair <dsinclair@chromium.org>
  - 41cbf0279c46f66aee1ca50c13c15fa23db753ff Reland ExternalTexture Gamma/Gamut Correction by Brandon Jones <brandon1.jones@intel.com>
  - 9432887ce845063ff1ffa5b6c90fb3e5ac94a3ba tint/sem: Add abstract int and float types by Ben Clayton <bclayton@google.com>
  - 26ebe5ec3644decb5d47d64580d50ab80a7c8c64 tint: Refactor if-else statement representation by James Price <jrprice@google.com>
  - 01004b7732abf4e2587a7d560828e49156ca6633 tint: Remove '_type' suffix from file names by Ben Clayton <bclayton@google.com>
  - 7e8df044c6506297cc830f3b34c6bd391c8791e5 tint/writer/spirv: Replace Operand with std::variant by Ben Clayton <bclayton@google.com>
  - 617570a7da4a30d4277f84f6c58f7d851114e47e tint/writer: Replace scope_stack_, fix type ctor scoping. by Ben Clayton <bclayton@google.com>
  - e85fe161cdaf2c464149a5a9d273437a3998c8e1 tint: ProgramBuilder: Rename Const() to Let() by Ben Clayton <bclayton@google.com>
  - 046abc08e850c95a6573bdeac6601ecf21f66ec5 tint/writer: Replace use of strings for cache keys by Ben Clayton <bclayton@google.com>
  - f7ec85f9bd532918a982b5130aa311c39bb4dab2 Rename UniformConstant to Handle. by dan sinclair <dsinclair@chromium.org>
  - 6bdd6592d9becdc5886c4c4f4487e849bfabc5e7 DEPS: Update Dawn standalone toolchains by Ben Clayton <bclayton@google.com>
  - 3b1e30a496e3b1e2ea92d37a84190fa0596f9948 tint: Add `i` suffix and validate UInt literal non-negative by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - 7098d3d692827ed973564c5e2371ee77ffbfb0d9 tint: Add enable directive for extensions by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - d3a5080c7bf8be17fce355a5f60223ab8271ece4 Fixup validator tests added during split from resolver. by dan sinclair <dsinclair@chromium.org>
  - 1d882f55b7f47dd06fe57efdf286100bf2a3ad6b Revert "Add External Texture Gamma/Gamut Correction" by Ben Clayton <bclayton@google.com>
  - f4a861dd60b9e5f89b31a5690cf01c47b11a5326 tint/fuzzers: Build protobufs after remove_stale_autogen_... by Ben Clayton <bclayton@google.com>
  - b52d740227043bc3e07dca0a98778b16d959eaea D3D12: Indirect validation shader name cleanup and parame... by Enrico Galli <enrico.galli@intel.com>
  - 857175e59b39e42fd21092fd4a96af9ea2c30297 Add External Texture Gamma/Gamut Correction by Brandon Jones <brandon1.jones@intel.com>
  - 67af2087583562f19ced01d659af7c6d4bda138a GN: Move dawn import into build_with_chromium cond by Ben Clayton <bclayton@google.com>
  - 25775308a98aef286d7d8ff2b62bd316beff8ed7 Implement support for Unicode Pattern_White_Space by Antonio Maiorano <amaiorano@google.com>
  - 790e4c2d60ffba5a0c20f209c94cdcdaa8bbd3d1 GLSL writer: emit gl_PointSize = 1 in all vertex shaders ... by Stephen White <senorblanco@chromium.org>
  - e6d7ea708a960a3fbc775ff3a5bcfb4c6a0b1043 tint: Use resolved source var in the Inspector by James Price <jrprice@google.com>
  - a9d8da4434efb043b8ad00ac0c2628f2ff44c209 tint: Use resolved source var in LocalizeStructArrayAssig... by James Price <jrprice@google.com>
  - 98eb1696920974aa18b960efb96a00ad4e7b2cce tint: Track originating variables in the resolver by James Price <jrprice@google.com>
  - eba0e85c335c5b55b03f5dfa9f37501b1959e7a2 tint: make Lexer use line breaks from Source::File by Antonio Maiorano <amaiorano@google.com>
  - a238e7bf9d639da9f8ce941cf58b3b7c2e6deef9 tint_generator_wgsl_corpus should wait for remove_stale_a... by Fumitoshi Ukai <ukai@google.com>
  - aacad7c65e80fdc1517348a5a4e7000ecec57d2e tint: Update FirstIndexOffsetTest expected results by James Price <jrprice@google.com>
  - 6cb57a9847f591b9ff53db529fb659098ddb4770 Change External Texture YUV-to-RGB Conversion to Use Matrix by Brandon Jones <brandon1.jones@intel.com>
  - f05575bb21584fda1e8e174470348c8d1679cf80 [tint] Move validation code into a Validator class. by dan sinclair <dsinclair@chromium.org>
  - 45ec7c352815154142de230588a769537da09389 D3D12: Duplicate first/baseVertex on Draw[Indexed]Indirect by Enrico Galli <enrico.galli@intel.com>
GitOrigin-RevId: 0ce9ab042ef5896b57833dd73dfa19fc94973b13
Change-Id: Ia8280f68ae3b4e53f42372ebc7d8e2db91ed1ada
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/87667
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
1133 files changed
tree: 17d9c4d7be9024c1affe07d8419269a8b78f16ee
  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.