Commit Graph

1776 Commits

Author SHA1 Message Date
Ben Clayton 26cd48603d Castable: Add FLAGS template argument for Is,As
[Is,As] contain a static_assert() that checks a cast is actually possible (TO -> FROM share a common base class).
This has been extremely valuable - it's caught numerious impossible casts due to stupid mistakes - however it makes certain generic templates impossible to write.

Add a compile-time FLAGS argument to Is() and As(), which accepts a new kDontErrorOnImpossibleCast flag.
When specified, this static_assert will always pass, allowing impossible casts to be attempted.

Change-Id: I5ff434b329c04d007f4e6976301bf30c73ab3f8d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47775
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-16 15:05:44 +00:00
Ben Clayton 7687ec1fa3 Kokoro: Test that the _other.cc files also build
Change-Id: I908b9250de839435c3b355fb89b0bb72ab821a54
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48043
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-16 14:43:34 +00:00
Ben Clayton fe70c75bc5 *_other.cc: Remove unused parameters
Change-Id: I966461fdf70a8d23c05f4e5daa5795b7c54e186b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48042
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-04-16 11:40:14 +00:00
Ben Clayton a2596bb696 Fix tmpfile_other.cc
Error: explicitly-defaulted constructor cannot have default arguments

This broke chromium, and needs fixing before we can restart the autorollers.

Change-Id: I4b04dd127b5fb7cf84e5782e07bcf68b2befc904
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48041
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-04-16 11:27:44 +00:00
Ben Clayton 316dcd4166 UintLiteral::to_str() suffix with 'u'
Fixed: tint:673
Change-Id: I5a58d9e504446ccff724e368b5ea2cf835d2271b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47768
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-04-16 10:44:54 +00:00
Ben Clayton 98b084e4a4 spirv/reader: Implement derivative intrinsics
Fixed: tint:719
Change-Id: Iaa5e44a574b2843f4f6f9264b8baa8d199acd70f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47770
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-04-16 10:43:34 +00:00
Ben Clayton 434cd396fe Move tools to a tools/src directory
Allows bash scripts to share the same name as the directory.

Add fix-tests bash script.

Change-Id: Iaf1943d50ec1fd3f382a2c7823fb7cdd13b1d9a2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47766
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-16 10:42:24 +00:00
Ben Clayton 648b05e4e2 Fix AttemptTintPadSymbolCollision test
This test landed simultaneously with a change that checks that storage buffers have an access qualifier, leading to broken tests.

Also fix lint issues that have crept in.

Change-Id: I4a7f0bc67d8d3e7170ddea117342a510741a495c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48040
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2021-04-16 10:37:34 +00:00
James Price 8cb5a23afb Automatically clone all symbols in CloneContext()
Almost all transforms should clone all symbols before doing any work,
to avoid any newly created symbols clashing with existing symbols the
source program and causing them to be renamed.

The Renamer is the exception to this, and so an optional flag is used
to prevent automatic cloning of symbols for this transform.

Bug: dawn:758
Change-Id: I84527a352825b2eaa43eabe225beb9e0999bf048
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48000
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2021-04-16 10:29:54 +00:00
Ben Clayton ed8332a0d1 writer/wgsl: Omit the newline after [[access()]] decorations
Produces ugly code for the common case.

Change-Id: I8e5b1215e19fc6461dc40b8a91922db25f9cbd76
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47764
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-04-16 10:09:44 +00:00
Ben Clayton bfae10525f writer/msl: Drop leading _ for _tint_pad_N fields
Bug: tint:640
Change-Id: I4415dcd2c46bff07bef302620321acc3847a6399
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47771
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-16 10:03:04 +00:00
Ben Clayton 1773535e1c Resolver: Validate <storage> var types
https://gpuweb.github.io/gpuweb/wgsl/#variable-declaration
Variables in the storage storage class and variables with a storage
texture type must have an access attribute applied to the store type.

https://gpuweb.github.io/gpuweb/wgsl/#module-scope-variables
A variable in the storage storage class is a storage buffer variable. Its
store type must be a host-shareable structure type with block attribute,
satisfying the storage class constraints.

Fixup tests, including those that were producing warnings about `var <in>`

The WGSL writer seems to want to put a newline after every decoration block, leading to some ugly output. I'll fix this as a separate change.

Fixes: tint:531
Fixes: tint:692
Change-Id: If09d987477247ab4a7c635f6ee6e616a06061515
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47763
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-04-16 09:26:14 +00:00
Ben Clayton 4485fcde64 fix-tests: Attempt to fix tests that use HasSubstr()
By comparing the old substring to the new full body, we can do a pretty
good job at creating a new substring.
This is not an exact science. Always carefully examine the newly
generated strings for correctness.

Change-Id: I8bdf591539a32ec42d0444aa054d88a933e4d250
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47765
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-16 08:58:44 +00:00
Ben Clayton 4db10dd496 Resolver: Handle AccessControl in Canonical()
The canonical type was stopping at the first encountered type::AccessControl, which meant the alias in access<alias<i32>> was not being unwrapped.

Bug: tint:705
Change-Id: Idcbd824808d8ee3098fb1861add5014d7d46b0ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47762
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-16 08:47:14 +00:00
Ben Clayton 856a3688f7 transform: Minor changes to cleanup Dawn usage.
Move transform::Transform::Output to transform::Output.
There's no need for this to be an nested class, it stutters, and it also
prevents Dawn from forward declaring it.

Add move assignment operator to DataMap.

Change-Id: Ibe1af03abc1a872790d20ee6ec8cf18a511ea0b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47772
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2021-04-16 08:35:24 +00:00
James Price fd7251bb02 Merge RenameReservedKeywords into the Renamer
Adds additional modes to the Renamer for renaming just HLSL or MSL
keywords. The sanitizers no longer rename reserved keywords
automatically, which isn't usually necessary anyway since Dawn renames
all symbols.

The tint executable automatically renames reserved keywords when
targeting HLSL and MSL. It now also has an option to rename
everything, which is useful for testing the renamer.

Change-Id: Idbfd53226805e851050024402be8d8f251b88707
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47960
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2021-04-16 08:28:54 +00:00
Antonio Maiorano fc03a46516 Validate array stride
Fix: tint:707
Change-Id: I4439b10f173d8753bd1d407629954a7dad61a679
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47826
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-16 02:36:44 +00:00
Antonio Maiorano 2e0bd4acb0 Resolver: improve array handling
type::Array was the only type with special handling in that we'd resolve
all array types first in ResolverInternal, then proceed with resolving
the AST in order of declaration. This CL removes this special handling,
and instead, we now process Arrays as we process ast::Variables of
array type. This change also allows us to pass down a Source location
for validation messages when processing Arrays.

Updated some Builder tests that weren't creating a variable of the array
type they declared.

Bug: tint:707
Change-Id: I8483b3a979bc1e5e04feb1ca4d281e96e9e654be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47825
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2021-04-16 01:15:43 +00:00
Ben Clayton 13ef87caab Validate that Symbols are all part of the same program
Assert in each AST constructor that symbols belong to the program of the parent.

Bug: tint:709
Change-Id: I82ae9b23c88e89714a44e057a0272f0293385aaf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47624
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-15 18:20:03 +00:00
Ben Clayton f0c816a757 ast: Validate that ASTs are all part of the same program
Assert in each AST constructor that child nodes belong to the program of the parent.

Bug: tint:709
Change-Id: Icc89b69691d099e358ff632a0ca6fd7943cb0193
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47623
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-15 17:47:23 +00:00
Ben Clayton 31804e09ed reader/spirv: Fix ExpectEq() tests
Don't end the EXPECT_THAT() with `<< ToString(p->builder(), fe.ast_body());`
This string is already emitted in the error, and calling ast_body() a second time triggers an assert as the builder is already finalized.

Change-Id: Ied6aca73937e86aa6ce2d8cff8a09f67b5082349
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47767
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-15 15:28:13 +00:00
Ben Clayton cc46e393e4 Add NOLINT to the new long test names
Suppresses cpplint warnings.

Change-Id: I2c8865709037b67f7af96e737dad8b6c179c5110
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47760
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-15 00:07:38 +00:00
James Price 0d96c1d644 transform/CanonicalizeEntryPointIO: Sort struct members
HLSL interface matching rules impose additional requirements on the
order of structure members. We now sort members such that all members
with location attributes appear first (ordered by location slot),
followed by those with builtin attributes.

Fixed: tint:710
Change-Id: I90940bcb7a5b9eeb1f50f132d406d4cf74e47ea2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47822
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2021-04-14 22:51:18 +00:00
James Price 172215e118 writer/hlsl: Fix mapping for [[builtin(front_facing)]]
Change-Id: I9493b8599e306113d4ede7b109adf5d119fbe4d6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47821
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-04-14 22:15:58 +00:00
James Price 0ba48eeb52 writer/msl: Enable validation for entry point tests
Fix a test that did not have the position builtin as a vertex shader
output.

Change-Id: I8dceba59d8327938e725e7d5e62b4b9c43695710
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47820
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-04-14 22:14:08 +00:00
James Price 43b84d69dd transform/CanonicalizeEntryPointIO: Fix symbol renaming
Pre-clone the program's symbols at the start of the transform,
otherwise the original program's symbols may get mangled. This causes
problems for Dawn when the entry point name is changed.

Change-Id: I414c798fb5f51afe44e8b97619f77452f97f0782
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47824
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
2021-04-14 22:08:48 +00:00
James Price edd4d3cc3b Rename builtin(sample_mask_{in,out}) to builtin(sample_mask)
Removes the need to pass the storage class to the SPIR-V reader
builtin mapping function.

Added a deprecation warning for sample_mask_{in,out}.

Bug: tint:715
Change-Id: I948ff2de2d5de7bd05e1c6ff45bd721c856900e3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47743
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-14 16:44:38 +00:00
James Price 88d7edcf7a Rename builtin(frag_coord) to builtin(position)
Use the variable storage class to determine the correct builtin to use
in the SPIR-V generator.

Added a deprecation warning for frag_coord.

Bug: tint:714
Change-Id: I5ad4956f9345e2f39f4af16e84668dec345ac82e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47742
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-14 16:37:18 +00:00
Arman Uguray d13982ff2e [msl-writer] Support MSL compiler validation in unit tests
The MSL writer GTest harness (TestHelper) now provides a function to
invoke the XCode SDK Metal compiler for the MSL output of a given
tint::Program.

The tint_unittests binary now provides the `--validate-msl` and
`--xcrun-path` command-line flags to optionally enable MSL validation
and to configure its path.

The MSL validation logic itself is conditionally compiled based on the
TINT_BUILD_MSL_WRITER define. The TINT_BUILD_* flags were previously
not propagated to the GTest binary which this CL addresses by linking
the common/public tint configs when building the tint_unittests_main
target.

Bug: tint:535
Fixed: tint:696
Change-Id: I08b1c36ba59c606ef6cffa5fa5454fd8cf8b035d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45800
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Arman Uguray <armansito@chromium.org>
2021-04-14 15:36:58 +00:00
Ben Clayton f8313e5a6e transform/BoundArrayAccessors: Fix symbol renaming
We need to pre-clone the source program's symbols before creating the symbols `min` and `arrayLength`, otherwise the original program's symbols will be suffixed with a number to make them unique.

Fixes Dawn tests that triggered this issue.

Bug: tint:712
Change-Id: Ie1cf6cbcf2050a2ce1a94acf0ae131a06f635820
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47761
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-14 14:29:28 +00:00
Ben Clayton 3dd4fae775 writer/hlsl: Use Symbols().New()
Instead of rolling another implementation inside GeneratorImpl.

Bug: tint:712
Change-Id: I26af0d68f6529c0c6dc45f51233f4618389edb55
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47638
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-13 23:48:07 +00:00
Ben Clayton 5c34060a4e transform/hlsl: Use Symbols().New() for empty entry point
And drop the leading understore, it's no longer needed.

Bug tint:712

Change-Id: Ic0ad304119ceb148984d2fa0a5e9e61f2c3a89fd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47637
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-13 23:46:17 +00:00
Ben Clayton 4d349b5391 transform: s/_tint_/tint_ for reserved keywords
Bug: tint:640
Change-Id: I7525ac97d8942fffa651847d703bf37a10cbc71d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47636
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-13 23:44:57 +00:00
Ben Clayton a5a31d35f6 transform/EmitVertexPointSize: Use SymbolTable::New()
And clean up some code in the process.

Avoids potential symbol collisions. Simplifies the logic.

Bug: tint:711
Bug: tint:712
Change-Id: I7c41dff81e1fb2abfd3f5d3fecf625a27c42f14d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47635
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-13 23:30:57 +00:00
Ben Clayton e6995de232 Add ProgramID feed it into all ast::Nodes
This will be used to detect accidental leaks of program objects between programs.

Bug: tint:709
Change-Id: I20f784a2c673d19a04a880b3ec91dfe2eb743bdb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47622
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-13 23:27:27 +00:00
Ben Clayton f01ed13a25 transform/VertexPulling: s/_tint/tint
Don't use a leading underscore in identifiers. Tint cannot parse these, they're illegal in MSL.

Bug: tint:640
Change-Id: I6e923cf3317a646cc5f4f2a10a7a522036000c70
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47634
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-13 23:08:37 +00:00
Ben Clayton 93cd23c01b transform/VertexPulling: Use SymbolTable::New()
And clean up some code in the process.

Avoids potential symbol collisions. Simplifies the logic.

Bug: tint:712
Change-Id: Ibce5ccbd4c7fd45d5bf29906b5a83b3637b6cdcc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47633
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-13 23:04:07 +00:00
Ben Clayton bd1597a545 transform/Renamer: Use SymbolTable::New()
Avoids potential symbol collisions. Simplifies the logic.

Bug: tint:712
Change-Id: I4416307b10f2dbe38964b6fd9342042c7e5505ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47632
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-13 22:58:07 +00:00
Ben Clayton 363a2e26e3 SymbolTable: Change behavior of anonymous symbols
SymbolTable::New() used to build and return a symbol without a registered name. When you asked for the name of the symbol it would return tint_symbol_N, where N is the numerical identifier for the symbol.

This approach was a major tripping hazzard for  transforms that liked to fetch the source program name, and register it in the new program (in this situation, you should always use `CloneContext::Clone(Symbol)`).
Without special casing for unnamed symbols, you could end up promoting the unnamed symbol to a named symbol, and then colliding against a new unnamed symbol.
This is exactly what happened in tint:711.

Instead, with this change:

* The concept of unnamed symbols has been removed. All symbols  now have a name.
* The signature of `SymbolTable::New()` has been changed to take a name parameter (which defaults to 'tint_symbol'). This can be used to create a new, unique named symbol (possibly with a suffix), which will not collide with any existing symbols. Note these symbols may still collide if `SymbolTable::Register()` is called with the same name. All Transforms that currently use `SymbolTable::Register()` will be fixed in another change.
* The CloneContext has been updated to use `SymbolTable::New()` instead of `Register()`. This means that any symbols defined before a clone will not collide.
* `CloneContext::CloneSymbols()` has been added which allows a transform to pre-clone all the symbols from the source program. This can be used to avoid the authored identifiers being suffixed with a number, in the case a transform calls New() before the symbol is cloned.
* `Symbol::to_str()` has been changed to return `$<id>` instead of `tint_symbol_N`. This is to avoid any confusion between the actual name and the symbol ID.

Bug: tint:711
Bug: tint:712
Change-Id: I526e4b49b7027545613859de487e6a275686107a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47631
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-13 20:07:57 +00:00
David Neto 46bb2bc935 spirv-reader: handle break and continue from if-selection header
Fixed: tint:243, tint:494
Change-Id: I6baf3360b44042b52f510b8f761376e1daab878f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47540
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Alan Baker <alanbaker@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-04-13 19:52:08 +00:00
Arman Uguray 66a8efc6ae Support optional file extension in TmpFile
TmpFile can now be supplied an optional file extension. This change
was motivated by validation work using the XCode SDK Metal compiler,
which expects a source file to end with the ".metal" extension.

See
https://developer.apple.com/documentation/metal/libraries/understanding_the_metal_shading_language_filename_extension

Bug: tint:535
Change-Id: I5d44baa20ba350530ace46569e238c4627135e51
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45720
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Arman Uguray <armansito@chromium.org>
2021-04-13 19:07:47 +00:00
Ben Clayton 5c3a7459e6 Add tools/fix-tests
A simple regex based tool for fixing unit tests that fail due to unexpected output

Change-Id: I72c47abaff6d6f4ba8cd497240eadc171af0fec3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47629
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-13 18:48:17 +00:00
Ben Clayton 12ac6e5d80 transform::VertexPulling - use DataMap for inputs
Migrate this transform to using the transform::DataMap pattern for configuration.

Allows users to fully construct their transforms ahead of time, and pass in the configuration options for each run.

Bug: tint:389
Change-Id: Ie4a8bf80d7b09cfe7bdd4ef01287d994b6b9eb4f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47626
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-04-13 18:46:47 +00:00
David Neto 0386472762 spirv-reader: fix overly aggressive dominance check
When finding the true-head, false-head, and potentially the
premerge-head blocks of an if-selection, there was an overly
aggressive check for the true-branch or false-branch landing
on a merge block interior to the if-selection. The check was
determining if the merge block actually corresponded to the selection
header in question.  If not, then it was throwing an error.

The bug was that this check must be performed only if the
target in question is actually inside the selection body.
There are cases where the target could represent a structured
exit, e.g. to an enclosing loop's merge or continue, or
an enclosing switch construct's merge.

There is still a latent bug: if either the true branch
or false branch represent such a kLoopBreak, kLoopContinue, or
kSwitchBreak edge, then those are not properly generated.
That will be fixed in a followup CL.

Bug: tint:243, tint:494
Change-Id: I141cce07fa0a1dfe5fad20dd2989315e4cd7b688
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47482
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Alan Baker <alanbaker@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-04-13 18:35:37 +00:00
Ben Clayton 095cd1c255 Fix symbol collision in RenameReservedKeywords()
Fixed: tint:711
Bug: tint:712
Change-Id: I8d0b5c926772c4265d273f6420f101f48ac29b9c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47628
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-04-13 17:53:09 +00:00
Ben Clayton ebc5bd4e28 Remove debug spew from test
Bug: tint:265
Change-Id: I9495c47fc1a4e70c6f6486c6357a41ddccd886c4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47625
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-13 14:20:13 +00:00
Antonio Maiorano 2543686412 Resolver: compute canonical types and store them as semantic::Variable::Type
We define the canonical type as a type stripped of all aliases. For
example, Canonical(alias<alias<vec3<alias<f32>>>>) is vec3<f32>. This
change adds Resolver::Canonical(Type*) which caches and returns the
resulting canonical type. We use this throughout the Resolver instead of
UnwrapAliasIfNeeded(), and we store the result in semantic::Variable,
returned from it's Type() member function.

Also:

* Wrote unit tests for Resolver::Canonical()

* Added semantic::Variable::DeclaredType() as a convenience to
retrieve the AST variable's type.

* Updated post-resolve code (transforms) to make use of Type and
DeclaredType appropriately, removing unnecessary calls to
UnwrapAliasIfNeeded.

* Added IntrinsicTableTest.MatchWithNestedAliasUnwrapping to ensure we
don't need to pass canonical parameter types for instrinsic table
lookups.

* ProgramBuilder: added vecN and matMxN overloads that take a Type* arg
to create them with alias types.

Bug: tint:705
Change-Id: I58a3b62538356b8dad2b1161a19b38bcefdd5d62
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47360
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-13 13:32:33 +00:00
David Neto 2f25ecf8ba spirv-reader: prove no const decls are created for handles
Fixed: tint:265
Change-Id: If175357d8c49707fd0cb69a811e972d9f808afe4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47561
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-12 21:01:22 +00:00
David Neto c3bbb4d079 Roll third_party dependencies
Roll third_party/gpuweb-cts/ dea8ed8c2..177a4faf0 (25 commits)

dea8ed8c2b..177a4faf0a

$ git log dea8ed8c2..177a4faf0 --date=short --no-merges --format='%ad %ae %s'
2021-04-06 enga Implement api,operation,rendering,draw:vertex_attributes,basic (#522)
2021-04-06 enga Implement api,operation,render_pipeline,primitive_topology:unaligned_vertex_count (#524)
2021-04-06 enga Convert primitive topology tests to a single parameterized test (#523)
2021-04-06 shrekshao Some depth related tests (#519)
2021-04-06 yunchao.he Fix a bug in createTexture validation for multisample (#521)
2021-04-05 enga node.tsconfig.json: include more files (#520)
2021-04-02 enga gen_wpt_cts_html: Split lines by either \r\n or \n (#517)
2021-04-02 enga checklist.ts: Split lines by either \r\n or \n (#518)
2021-03-31 enga Fix multicase test expectation filtering (#516)
2021-03-30 enga WPT: Pass expectations to worker.run (#515)
2021-03-25 shrekshao Fix wgsl .0 suffix to indicate f32 type (#514)
2021-03-25 hao.x.li Clean up TODOs for queries validation (#511)
2021-03-24 enrico.galli Add validation tests for setBindGroup (#493)
2021-03-24 enga Fix check of `loadWebGPUExpectations` for undefined (#512)
2021-03-18 kainino Add stubs for new tests and organize a few old ones (#510)
2021-03-19 jiawei.shao Add validation tests on buffer offset in B2T and T2B copies with depth stencil formats (#506)
2021-03-18 2154796+austinEng Support passing skip/fail test expectations in wpt or by command line (#509)
2021-03-18 kainino capability_checks tests should expect exceptions not validation errors (#508)
2021-03-18 2154796+austinEng Implement api,operation,rendering,draw:arguments:* (#498)
2021-03-18 hao.x.li Add validation tests plan for Occlusion Query (#491)
2021-03-11 kainino Add a tool to verify tracking spreadsheet
2021-03-17 kainino move an error out of loadTreeForQuery
2021-03-17 kainino add includeEmptySubtrees to iterateSubtreeCollapsedQueries
2021-03-17 kainino Add StacklessError for less annoying fatal errors in scripts
2021-03-17 2154796+austinEng Don't validate test modules in `makeListing` (#507)

Created with:
  roll-dep third_party/gpuweb-cts

Change-Id: I60610afcd9533fc6905134a1b224c9946a475316

Roll third_party/spirv-tools/ 4f498774d..212895d4c (21 commits)

4f498774db..212895d4c2

$ git log 4f498774d..212895d4c --date=short --no-merges --format='%ad %ae %s'
2021-04-02 alastair.donaldson Typo fix (#4225)
2021-03-31 greg Add interpolate legalization pass (#4220)
2021-03-27 alastair.donaldson spirv-fuzz: Efficiency improvements to fuzzer pass (#4188)
2021-03-27 alastair.donaldson spirv-fuzz: Avoid invalidating analyses when splitting blocks (#4218)
2021-03-27 alastair.donaldson spirv-fuzz: Do not add too many dead blocks (#4217)
2021-03-26 alastair.donaldson spirv-fuzz: Optimize transformations (#4216)
2021-03-25 vasniktel spirv-fuzz: Fix comments #4215
2021-03-24 jason Add validation for SPV_EXT_shader_atomic_float_min_max (#4105)
2021-03-23 dneto Make spirv-tools-build-version a common dependency (#4210)
2021-03-23 alastair.donaldson spirv-fuzz: Call by value and move in transformations (#4208)
2021-03-23 alastair.donaldson spirv-fuzz: Remove destructors from FuzzerPass subclasses (#4209)
2021-03-23 alastair.donaldson spirv-fuzz: Improve transformation test oracles (#4207)
2021-03-21 vasniktel spirv-fuzz: Add WGSL compatibility flag to context (#4193)
2021-03-20 alastair.donaldson spirv-fuzz: Avoid invalidating analyses in various transformations (#4205)
2021-03-20 alastair.donaldson spirv-fuzz: Manage available instructions efficiently (#4177)
2021-03-20 alastair.donaldson spirv-fuzz: Remove AddType methods from fuzzerutil (#4204)
2021-03-19 46493288+sfricke-samsung spirv-val: Refactor of atomic pass (#4200)
2021-03-19 46493288+sfricke-samsung spirv-val: Label VUID 04643 (#4202)
2021-03-19 46493288+sfricke-samsung spirv-val: Label VUID 04667 (#4201)
2021-03-19 alastair.donaldson spirv-fuzz: Apply fuzzer pass before checking exit conditions (#4199)
2021-03-18 46493288+sfricke-samsung spirv-val: Fix Int64Atomics check (#4192)

Created with:
  roll-dep third_party/spirv-tools

Change-Id: Ieac13912b9899fe70b8b304f717f0f5e10155199

Roll third_party/spirv-headers/ bcf55210f..f88a1f98f (2 commits)

bcf55210f1..f88a1f98fa

$ git log bcf55210f..f88a1f98f --date=short --no-merges --format='%ad %ae %s'
2021-03-25 michael.kinsner Add xml section for memory operand bit allocation tracking, and reserve two bits for an upcoming Intel extension
2021-03-24 baldurk Add NonSemantic.Vulkan.DebugInfo.100 JSON/header

Created with:
  roll-dep third_party/spirv-headers

Change-Id: Ia59440c53433e5624d5d1d090ec5b9c194ba5c21

Roll third_party/googletest/ b7d472f12..5c8ca58ed (14 commits)

b7d472f122..5c8ca58edf

$ git log b7d472f12..5c8ca58ed --date=short --no-merges --format='%ad %ae %s'
2021-04-05 absl-team Googletest export
2021-04-02 absl-team Googletest export
2021-03-25 absl-team Googletest export
2021-03-24 absl-team Googletest export
2021-03-24 absl-team Googletest export
2021-03-24 absl-team Googletest export
2021-03-24 absl-team Googletest export
2021-03-23 absl-team Googletest export
2021-03-22 absl-team Googletest export
2021-03-22 absl-team Googletest export
2021-03-22 absl-team Googletest export
2021-03-20 absl-team Googletest export
2021-03-14 zekewarren Use @platforms instead of @bazel_tools for windows constraint
2020-12-04 zed.three CMake: Add namespaced ALIAS library

Created with:
  roll-dep third_party/googletest

Change-Id: I07e2fbdda46a67d76797c08f4266d311404150de
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47022
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-04-12 14:41:32 +00:00
James Price c8ffbe43a7 Output all diagnostics from tint executable
Otherwise warnings are not emitted unless there is also an error.

Change-Id: If417f75fbdd246b1f792a0f63b83274c8f2272e3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47481
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-04-09 20:14:18 +00:00