Import Tint changes from Dawn

Changes:
  - b32f9ca75b28abdbc0b8c25817de6641f2c71989 [tint][wgsl] Simplify IRToProgramTest by Ben Clayton <bclayton@google.com>
  - d56afc4261e2d046a7d8e424be372487ec149c18 Remove materialize from core defs. by dan sinclair <dsinclair@chromium.org>
  - a3430744b3c198bc3ad7e28dc94297f3b8e04ff9 [tint][ir] Validate user call arguments by Ben Clayton <bclayton@google.com>
  - addf27edd4bd0f14ad3c459099f51195078929f6 [tint] Minor code refactor by Ben Clayton <bclayton@google.com>
  - 47236f1ef5f29b90d32c7a591fadb38d321ba6ff [tint] Fix the datatype conversion in socket.cc by Sonakshi Saxena <nexa@google.com>
  - becf2538e8896d1538d0e02e05c5e8022337b505 [tint] Improve unit test failure output. by Ben Clayton <bclayton@google.com>
  - 9887c6ea389dfd01bec84e39aecbf07ead777d94 [tint][ir] Validate store target type by Ben Clayton <bclayton@google.com>
  - fa41628b03f1c048b024e32581d4ec9404e88d1c [spirv-reader] Handle UBO variable decorations by James Price <jrprice@google.com>
  - 2e2bf7b923ee30485fd134326345a6233e0884c2 [spirv-reader] Handle Op{AccessChain,Load,Store} by James Price <jrprice@google.com>
  - bd9da033ea5b4242217b1343d16eaf9c2d098d44 [spirv-reader] Add Emit() and AddValue() helpers by James Price <jrprice@google.com>
  - df41dad13f79f66e81d8693a10f44d67a2edbec7 Add new SPIRV AST fuzzer. by dan sinclair <dsinclair@chromium.org>
  - 41cdde73fbc97afbe4de286d3180ad3420ca1fbc [tint][lang] Standardise lower / raise namespaces by Ben Clayton <bclayton@google.com>
  - 31295c47ea224ae63b63bb78bd3f989074224f46 Add new GLSL fuzzer by dan sinclair <dsinclair@chromium.org>
  - 91c5d6a2295dc2edd533de1935b92754690e23bb Add new HLSL fuzzer by dan sinclair <dsinclair@chromium.org>
  - 2fe1f267e72e4e4e1b903b7c70f517c6d690c4e1 Add reflection for Access enum. by dan sinclair <dsinclair@chromium.org>
  - 8a000ce7786b702fa12cee14160588dda6f6af5a [ir]: polyfill dot4I8Packed, dot4UPacked when needed by David Neto <dneto@google.com>
  - 6140a5998637a8b64a83c4da189d02af11a503f2 Add Vector to byte decoder. by dan sinclair <dsinclair@chromium.org>
  - d98c29e4403851696da11684c6f45ca840defd16 Additions to generator code. by dan sinclair <dsinclair@chromium.org>
  - 514a18aed3fc6cbef08cfab57fc3b5155f6f84b9 [tint][ir] Use intrinsic table for binary ops. by Ben Clayton <bclayton@google.com>
  - fa72454f21104406d53b6ca324c5fa65f03097a5 Add new MSL fuzzer by dan sinclair <dsinclair@chromium.org>
  - 53edc77f378a6ff6837c75a8150fae179008e210 dp4a: fix Tint IR polyfills for unpack4x[IU]8 by David Neto <dneto@google.com>
  - 1dc345789819bfa6509fe4fb3ecae600ddd6de2f [tint][ir] Add an IR binary roundtrip fuzzer by Ben Clayton <bclayton@google.com>
  - b865a1e88666f21dc094e0218f12459e0743660c [tint][ir] Use intrinsic table for unary ops. by Ben Clayton <bclayton@google.com>
  - 825f6265f4435d0aba4eaa60e5b6fa7938c513fc Add toggle to disable Tint polyfills on integer division ... by Jiawei Shao <jiawei.shao@intel.com>
GitOrigin-RevId: b32f9ca75b28abdbc0b8c25817de6641f2c71989
Change-Id: Ib87d37962a5220b36e44adc9989e61f001c7b599
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/168760
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
162 files changed
tree: 86f8f7f888356c5576d4dbe00e7ae7a22ebc99f7
  1. .vscode/
  2. build_overrides/
  3. docs/
  4. include/
  5. infra/
  6. kokoro/
  7. scripts/
  8. src/
  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
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.