Commit Graph

1818 Commits

Author SHA1 Message Date
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
James Price 3ee8c37cb6 [wgsl-reader] Deprecate old syntax for entry point IO
Bug: tint:697
Change-Id: Ia6e066678753ef12dc41a753ba33c924bb662148
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47480
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-04-09 19:58:58 +00:00
Ben Clayton 6f7986d9b5 writer/hlsl: Use SampleCmpLevelZero instead of SampleCmp
Currently WGSL does not allow a mip-level to be specified for `sampleCompare`, and cs_5_1 does not allow SampleCmp to be used.

Bug: tint:684
Change-Id: I53f35205185a0a1ee0dd5224fa1d8cd0ffedbea1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47429
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-09 18:20:18 +00:00
Ben Clayton 804a699ea5 writer/hlsl: Include format type for sampled textures
Required for correct output of .Load() functions

Bug: tint:689
Change-Id: I5e5ea068700bbe2239f04dc81da9acb7abce0210
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47225
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-09 17:50:08 +00:00
Ben Clayton 6a802cd3e4 writer/hlsl: Move the renamer into the sanitizer transform
The renamer logic in the HLSL writer was inconsistent, and actually
broke some valid shaders.

Change-Id: I8fbddc7e657f5509b18435fdf352a39d83c1b89c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47224
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-09 17:28:18 +00:00
Ben Clayton 003fa8ffd6 Remove LocalReferencedBuiltinVariables()
It ignored entry point builtin parameters, meaning it was mostly useless.
Was only used by the FirstIndexOffset, which has been re-written.

Change-Id: I26abd69201576cf33b1a71e8e6a1b914871a2a74
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47223
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-09 16:54:48 +00:00
Ben Clayton 962d46ec56 Fixup all doxygen warnings
No idea why the operator<<() functions have started moaning now.

Change-Id: I338b96c53888f4ddb8e42283a6dcda7708e567f0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47431
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-09 16:51:38 +00:00
Ben Clayton 1d618b1664 transform: Reimplement FirstIndexOffset
* It didn't always produce valid WGSL (crbug.com/tint/687)
* It didn't handle builtins as entry point parameters
* It used hard-coded symbols that could collide
* It didn't use DataMap for input.

The new implementation addresses all of this.

Bug: tint:687
Change-Id: I447bec530b45414ebb8baeb4ee18261d73d1c0d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47222
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-09 16:19:48 +00:00
Ben Clayton e9c4984489 semantic: Add Function::Parameters(), MemberAccessorExpression subtypes
Add semantic::Swizzle and semantic::StructMemberAccess, both deriving from MemberAccessorExpression

Add semantic::Function::Parameters() to list the semantic::Variable parameters for the function.

Change-Id: I8cc69f3738380c14f61d051ee2989be6194d148d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47220
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-09 13:56:08 +00:00