Import Tint changes from Dawn

Changes:
  - c0d51f1cd8945d035ed9ff83bd37d89cbf7e3de2 tint: spirv reader: detect and replace loads and stores o... by Antonio Maiorano <amaiorano@google.com>
  - c7d6ab6c5af7b3da8665ebac74408d9d5dcbd96d tint: Prevent function calls at module-scope by Ben Clayton <bclayton@google.com>
  - aa037ac489cde4ae1ec289e7927821c89d6c579d tint: Refactor sem::Constant to be less memory-hungry by Ben Clayton <bclayton@google.com>
  - cf52af7b0f2d5bf7764ff9c3840c1ac38fb1ccb9 tint: Have Number equality consider sign by Ben Clayton <bclayton@google.com>
  - 3a2a27971487769c4581c876ea379854a4fe997a Fixup various warnings in Tint which were accidentally su... by dan sinclair <dsinclair@chromium.org>
  - 2b4df7889186d2e98e437a2d1bb3e083b4722edb tint/number: Fix CheckedConvert() logic by Ben Clayton <bclayton@google.com>
  - 72876c14c3dc5fb947da619ef1fbb4faa9e98a3e tint/sem/constant.h: Remove #include to program_builder.h by Ben Clayton <bclayton@google.com>
  - c64ca23d94aae25c5573bb4ad354a8686fba285c tint: Deprecated module-scope 'let' for 'const' by Ben Clayton <bclayton@google.com>
  - d23f296a9a31daa764d348169d3ae13d5a09877b tint: Implement acosh, asinh, atanh by dan sinclair <dsinclair@chromium.org>
  - 6058882d4bf54d47d79ad528561ac89f66ec199a tint/resolver: Add f16 types, constructor, and conversions by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - 53af15836660ebd851702ebc1551dca0d0447249 tint/reader: Allow module-scope 'var' type inferencing by Ben Clayton <bclayton@google.com>
  - 19576e9015d2b2ce7a1933ec14606748a6902ead tint/writer: Handle and emit 'const' variables by Ben Clayton <bclayton@google.com>
  - 6c167a0dc78380dfc5d60623aa435af80066b910 msl: Promote local private vars to function scope by dan sinclair <dsinclair@chromium.org>
  - 7ebcfc7e0e2ad76202a77325d1e8dd82322c5d2a tint/transform: PromoteInitializersToLet by Ben Clayton <bclayton@google.com>
  - ce466c0df3d8474e61dff2315aa8de1c722d82eb tint: spir-v writer: Fix matrix constructor from matrix v... by Antonio Maiorano <amaiorano@google.com>
  - 54b3da95f808f14b913cbfe8132e7977246f443b tint/transform: Handle 'const' for Unshadow. by Ben Clayton <bclayton@google.com>
  - fcf9fdcad813691915fc313a7a1af1bbf3d9523f tint/writer/wgsl: Emit 'const' variables by Ben Clayton <bclayton@google.com>
  - f90313396b63da549e8c535aaa577d9fe1dea5a1 tint/reader/wgsl: Drop const_expr parsing by Ben Clayton <bclayton@google.com>
  - e48ef8ef9070c319c0a3beb372076948c2131437 tint/reader: Enable 'const' parsing for unit-tests by Ben Clayton <bclayton@google.com>
  - 511529f082daa0ae7f803024dfbce1ba1e0e9fe3 tint/resolver: Clean up workgroup-size error diagnostic by Ben Clayton <bclayton@google.com>
  - 410a3bd19a06889017740633b5cf421d70ccf664 tint/resolver: Propagate constant values between 'const's by Ben Clayton <bclayton@google.com>
  - e3834c47604ebccf4337604612eec1f51411a7bb tint/resolver: Resolve 'const' variables by Ben Clayton <bclayton@google.com>
  - 01208e7e42ae6c56b4fdb2618ff72e91708a2206 tint: Rename Global() -> GlobalVar() by Ben Clayton <bclayton@google.com>
  - 41486e11350217e4e50480411305889384beff4f tint: Rename GlobalConst() -> GlobalLet() by Ben Clayton <bclayton@google.com>
  - b4ff8c859a26e8ac060062198cfaf35d6b8c4520 tint/resolver: Simplify array size evaluation by Ben Clayton <bclayton@google.com>
  - 268d7b83571ae65b7e59a6df251ecb6ac0f5a806 tint: Add support for atomic ops to spirv reader by Antonio Maiorano <amaiorano@google.com>
  - ebed939759cb7b6fc9725e9430093166d7e7c21b tint/resolver: Tidy up variable_test.cc by Ben Clayton <bclayton@google.com>
  - 68ae36e43d1e7b6d8138bb1a794b2d3614a31f6e tint/resolver: Rename var_let_*test.cc -> variable_*test.cc by Ben Clayton <bclayton@google.com>
  - dfeaf29055e17d1a01caa7c69af50e577808cfda tint: Add sem::IndexAccessorExpression by Antonio Maiorano <amaiorano@google.com>
  - 32cb9cf2f8ae5937c3ad45de39cb0638309502fd tint/writer: Disable constant inlining for lets by Ben Clayton <bclayton@google.com>
  - c5f7e8f0bc9983a9010c5353932601b40bd45ae7 tint: Fix emitting identity matrix ctor in HLSL by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - f47887d2073504bf13152ff5ae142a6653ba322c tint/writer/msl: Generate an array<T,N> helper by Ben Clayton <bclayton@google.com>
  - 3c054304a8fc579ea085d44af010e470cb591921 tint/sem: Support arrays for sem::Constant by Ben Clayton <bclayton@google.com>
  - e8d47d52636e9499915422a53ccde978b24feb02 tint/sem: Add more checks to constant_test.cc by Ben Clayton <bclayton@google.com>
  - ab70ff7a2fc355defd4558aeb75914e10f5f3610 tint/writer/spirv: Clean up accessor tests by Ben Clayton <bclayton@google.com>
  - 3a68ab4a1718e6eb23d21d2eb4d0db14ecdf4b6d tint/writer: Minor generator cleanup. by Ben Clayton <bclayton@google.com>
  - 50414807150bdac9f41817fea7bdf939425768be tint/writer: Clean up EmitConstant() methods by Ben Clayton <bclayton@google.com>
  - 18b966321bca9ed2a7787c0adbbb18d013fac43e tint: remove duplicated ending newline in ctor_conv_intri... by Zhaoming Jiang <zhaoming.jiang@intel.com>
  - c1cb9dc1a5c038ad2d3bad0edc852688f638d9ac tint/resolver: Evaluate constant index accessors by Ben Clayton <bclayton@google.com>
  - f99671b830811d33dc1d1e234c4b66300ed007a7 tint: spir-v reader: fix atomicCompareExchangeWeak with v... by Antonio Maiorano <amaiorano@google.com>
  - 77bf233cef236a094ef845d8f1a31073c2ddd7b9 Move tint unittest behind a build flag. by dan sinclair <dsinclair@chromium.org>
  - 1ed376be34219ad52892fcb3b83787cfc026e9b4 tint/sem: Add range overload of Constant::AllZero() by Ben Clayton <bclayton@google.com>
  - ef62b58cf96ea4d0f0f22fac1d0c768e15aab00c Skip Gamma and Gamut conversions for BT.709->SRGB by jchen10 <jie.a.chen@intel.com>
  - 797f0f82e0521a4aaaad3004dc281df6581c693e tint/sem: Return vector for Type::ElementOf(matrix) by Ben Clayton <bclayton@google.com>
  - 44eb10814e2aa8b07c96573bd268cf2ea15d97b7 tint/resolver: Change return type of EvaluateConstantValu... by Ben Clayton <bclayton@google.com>
  - e021566617d6c705387c4faf4f95f1501995845a tint/reader/wgsl: Lex 'const' by Ben Clayton <bclayton@google.com>
  - 3b3ef3624120551e2599c6a02bee1e8de3b01b0f tint/sem: Add Type::DeepestElementOf() by Ben Clayton <bclayton@google.com>
  - 7ee324551c65bff676039448b1440ff6646ef9c0 tint/ast: Add 'const' AST node by Ben Clayton <bclayton@google.com>
  - 42fdeb2c8cf26a18c2bf7687cbe492a8ae46e3e5 Remove test/tint/BUILD.gn by dan sinclair <dsinclair@chromium.org>
  - 22d8dea091662c05e0ec510e0d67995cd2153618 tint/resolver: Fix ICE when failing to materialize by Ben Clayton <bclayton@google.com>
  - e4e4854b77c3bce27996d86cbcfbed0b158397df tint/resolver: Clean up 'let' / 'override' resolving by Ben Clayton <bclayton@google.com>
  - ee49b1ed9550b8a8a0018ea51d76613b2dd5a5e4 tint/resolver: Clean up 'var' resolving by Ben Clayton <bclayton@google.com>
  - 80fdd624a0919ed5578a3e8c1c0b18b3d347e1b4 tint: Process functions in dependency order by James Price <jrprice@google.com>
  - 46583621c0b17e72da334b2471898104e101406c tint: Refactor ModuleScopeVarToEntryPointParam by James Price <jrprice@google.com>
GitOrigin-RevId: c0d51f1cd8945d035ed9ff83bd37d89cbf7e3de2
Change-Id: I772e94e59da83e6466a1694a708186bdc03119ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/95260
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
296 files changed
tree: 5d78bdb13685f87eb6bdd8b5e43791bb1ab02ed0
  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.