Commit Graph

674 Commits

Author SHA1 Message Date
Ben Clayton b833f1572b reader/spirv: Remove use of BlockStatement::append()
Introduce `StatementBuilder`s , which may hold mutable state, before being converted into the immutable AST node on completion of the `BlockStatement`.

Bug: tint:396
Bug: tint:390
Change-Id: I0381c4ae7948be0de02bc13e54e0037a72baaf0c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35506
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-12-14 19:48:47 +00:00
David Neto 2353bd0d3d spirv-reader: convert coordinate type when unsigned
In SPIR-V, coordinates for ImageRead, ImageFetch, ImageWrite are
integral.  When they are unsigned, they must be converted to signed.

Fix tests for image sampling and dref sampling that used integer
coordinates. SPIR-V requires them to be floating point.

Bug: tint:109
Fixed: tint:346
Change-Id: If33c8970b9d8f7d934d3e582194fe6ed83eff7e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35560
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-12-14 17:31:37 +00:00
dan sinclair 24bbbbb25f Add Symbol to struct type.
This CL adds a Symbol to the struct type along side the name. The name
will be removed in a future CL when the symbol is used everywhere.

Change-Id: I6c355908651ba0a155a1e0c9ed1192313a405568
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35620
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-14 16:01:37 +00:00
Ben Clayton bcf37549c8 ast: Remove Struct constructors that don't take a Source
And swap the `decorations` and `members` parameters, as decorations come last for other constructors.

Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: Ie9b814c1de24b6c987f0fbb9e6f92da7c352caa2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35163
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 12:52:44 +00:00
Ben Clayton 4543d1a232 ast: Remove StructMember constructor that doesn't take a Source
Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: Ie9f8f7428d2308c3b1a9a8d2137e2e3c6d1d13e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35162
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 12:18:04 +00:00
Ben Clayton bbefff63a3 ast: Remove statement constructors that don't take a Source
Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: I137f1017ca56125cf3d52ecbef2ff46d0574338b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35161
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 11:58:44 +00:00
Ben Clayton 1ff59cd0e2 ast: Remove expression constructors that don't take a Source
Parsers need fixing up.

Bug: tint:396
Bug: tint:390
Change-Id: I7f823e2489101b43c1b21a6b89c248695a3f35b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35160
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 01:38:13 +00:00
Ben Clayton 5ed161b2d9 ast: Add Source argument to literals
Bug: tint:396
Bug: tint:390
Change-Id: Ib78c19533dc65c85e2381bf1ce0d0966dd7babe9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35019
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 01:35:43 +00:00
Ben Clayton 604bc72dd9 ast: Remove Node::set_source()
All nodes that don't have a Source constructor will need to have one added.
We can then find all missing Source mappings with a search for `Source{}`

Bug: tint:396
Bug: tint:390
Change-Id: I06f9689d4da0f3fd1bd757c7358dcc65f15dc752
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35018
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-12 01:24:53 +00:00
dan sinclair 4226b6a1d8 Add Symbol to alias.
This CL adds a Symbol alongside the name in the Alias type. The name
will be removed in a future CL.

Change-Id: I23fa77566cc7a2aead783b64c34c0cc3195df24b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35461
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-11 19:35:03 +00:00
dan sinclair 6b59bf45aa Add a symbol to the Identifier AST node
This CL adds a Symbol to the identifier to represent the name. The name
still exists but will be removed in a future CL when the namers are in
place.

Change-Id: Ic3cc8ad0d99e3bea6eb1ff1ce212e7de67991aec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35460
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-11 19:16:13 +00:00
David Neto 5b3c9f1c62 spirv-reader: refactor, add ToI32 helper
- The create function is available locally without needing
  to go through ast_module_.
  But go through ast_module_ during member initialization.
- Add ToI32 helper.
  - Use it during possible conversion of the sample index

Bug: tint:3
Change-Id: I8224119f780486d769697910dfa3dd9fb5413259
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35541
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-11 18:35:43 +00:00
dan sinclair a41132fcd8 Add a symbol to the Function AST node.
This Cl adds a Symbol representing the function name to the function
AST. The symbol is added alongside the name for now. When all usages of
the function name are removed then the string version will be removed
from the constructor.

Change-Id: Ib2450e5fe531e988b25bb7d2937acc6af2187871
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35220
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-11 18:24:53 +00:00
David Neto cd9e5f6e91 spirv-reader: Support multisampled textures
Only ImageFetch is supported.

Converts the signedness of the sample operand as needed.

Bug: tint:109
Bug: dawn:399
Change-Id: I1d00ff4452af123457bb1841d872afcf2c591c48
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35540
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-12-11 18:19:33 +00:00
Ben Clayton a80511e021 ast: Merge DecoratedVariable into Variable
Remove all Variable setters (with exception to set_storage_class() which is called by the TypeDeterminer)

Bug: tint:390
Change-Id: I172667e21e2b02e85dcea6703aa1e608ec718250
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35015
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-11 13:07:02 +00:00
David Neto ccc67252ff spirv-reader: support OpBitCount, OpBitReverse
Bug: tint:3
Change-Id: I81580136621ab51a9852e1d692ddad2457b9aab9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35340
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-10 18:51:51 +00:00
David Neto 287f6f12ef spirv-reader: support more integer builtins
Support:
 - SAbs
 - UMax, SMax
 - UMin, SMin

Add tests for operand and result conversion for UClamp.
SClamp was already tested.

Bug: tint:3
Change-Id: I9b9278843ca5243991b330b27764756137da4ee4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35302
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-12-10 15:22:51 +00:00
David Neto 3ca59444cd spirv-reader: remove redundant disabled test
Testing result signedness conversion was already covered
in https://dawn-review.googlesource.com/c/tint/+/35180

Change-Id: I2f7b1caf512ceb81fbe2ea6a2037de61dea25c96
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35360
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-10 15:22:11 +00:00
David Neto 5213c400eb spirv-reader: convert signedness of texturing result when needed
Fixed: tint:382
Change-Id: I786e1f5d5d122a82ef29c733e514bf3b45651c5d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35180
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 17:09:50 +00:00
Ben Clayton 7f04e5c1e2 Implement textureLoad()
Bug: tint:140
Bug: tint:143
Bug: tint:144
Bug: tint:145
Bug: tint:146
Bug: tint:147
Change-Id: I8f41abac2e355c121e8868aa708ae51d0db87665
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34960
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 15:57:00 +00:00
David Neto 350330bb46 spirv-reader: Fix signedness for extended instructions
SClamp is the only implemented instruction that is affected, so far

Bug: tint:405
Change-Id: I21c1cdd3e70fc3a64046f0473569ba906048cd37
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35240
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 04:18:36 +00:00
David Neto 6ff8cdb991 spirv-reader: support ldexp
Bug: tint:3
Change-Id: I6a9204b19c5b4d631634b9a585a0081eaead9c1b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35046
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-09 04:13:46 +00:00
David Neto 195917c0be spirv-reader: Support many more float builtins
Also map FClamp, FMin, FMax to WGSL "clamp", "min", and "max".
The behaviour of FClamp, FMin, and FMax doesn't specify
much when operands are NaN.  Map to WGSL functions
which are more prescriptive about results when operands are NaN.

Also add TODOs for the GLSL.std.450 instructions that I had
missed earlier: the interpolate-at instructions

Fixed: tint:214
Change-Id: I10f7df66875ccda968fc5654b4f1c1d3a6ac23ca
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35062
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-08 14:29:03 +00:00
David Neto eb7865cd0d spirv-reader: Support NClamp, NMin, NMax
Also map FClamp, FMin, FMax to WGSL "clamp", "min", and "max".
The behaviour of FClamp, FMin, and FMax doesn't specify
much when operands are NaN.  Map to WGSL functions
which are more prescriptive about results when operands are NaN.

Also add TODOs for the GLSL.std.450 instructions that I had
missed earlier: the interpolate-at instructions

Change-Id: I48503be68128d2a0659bef7057e890cb9c0617ad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35080
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-07 23:45:47 +00:00
Ben Clayton 8b0ffe9185 ast::type: Remove Array::set_decorations
Move to constructor

Bug: tint:390
Change-Id: If6c65b7305db7f9977c0cc9884a8f551e07de050
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35014
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-12-07 22:19:27 +00:00
Ben Clayton 602c025aa0 ast: Remove Function::set_body()
Bug: tint:390
Change-Id: I525086868c6470ba39fe8c4ede7390e74c9489ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35012
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:17:47 +00:00
Ben Clayton d0dda258cc ast: Remove ReturnStatement constructors that don't take a source
set_source() will be removed, so sources will only be specifiable at construction time.

Bug: tint:390
Change-Id: I2b81929e362ccf75145ebc45028dd973a77ae068
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35010
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:09:57 +00:00
Ben Clayton 321e5a9d7e ast: Remove Variable constructor that doesn't take a source
set_source() will be removed, so sources will only be specifiable at construction time.

Bug: tint:390
Change-Id: I5c79efd3fa501ebd9308f7f93cfb77bc12198047
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35009
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 21:08:07 +00:00
David Neto b4b29639a1 spirv-reader: simplify GLSL.std.450 tests
Use variables with names rather than constants
which elaborate to a lot of text in the AST.

Change-Id: Ic284bbd4019e50308c5836768df01c6a9525c004
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35061
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-07 21:02:27 +00:00
David Neto 201fa87a6d spirv-reader: list missing GLSL.std.450 instructions
Add a TODO for them

Change-Id: I038e4384ae44d87544ae040b2e5ba193415e01b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35060
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-07 20:55:07 +00:00
Ben Clayton 234b7de460 ast/function: Remove [set|add]_decorations()
Move them to the constructor

Bug: tint:390
Change-Id: I30bb6a1de060b790bf5202194d020d4e3889a307
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35008
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 20:45:14 +00:00
Ben Clayton 9838768599 ast: Remove IfStatement::set_else_statements()
Move it to the constructor.

Bug: tint:390
Change-Id: Ib4ac1a1c83aa59963472ac7c14c9e0cbcf2734e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35007
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 20:11:24 +00:00
David Neto 4d6635858e spirv-reader: support UClamp, SClamp
Fixed: tint:383
Change-Id: I101370a82379363a4fb1f725e010eedc2da059ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35042
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-12-07 19:53:54 +00:00
David Neto 4f8b96e13c spirv-reader: texture level and array index are signed
Fixed: tint:394
Change-Id: Ic81c7167d65e7a8d09363a62848b74928fdc2798
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35043
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-12-07 18:17:14 +00:00
dan sinclair c35176eadf Remove the context object.
This CL strips the context object out of Tint.

Change-Id: Id0dcb9c557b217c03a8d9ac08fc9fe1c799f3fdc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34742
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-07 16:03:54 +00:00
Ben Clayton bd018d254d Improve error messages raised by SpvParserTest
EXPECT_THAT(xxx, Eq(yyy)) << ToString(xxx);

is a less-idiomatic way of writing:

  EXPECT_EQ(xxx, yyy);

The latter also provides a diff when two strings do not match.

Refactor these to:

  auto got = xxx;
  auto expect = yyy;
  EXPECT_EQ(got, expect);

So that the error message clearly shows which one is the generated, and which one is the reference.

Change-Id: I299204a615aa3e68cd82d19ce892ab33aabe2f08
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35006
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-07 15:57:04 +00:00
dan sinclair 685cb02ea8 Remove internal usage of Context.
This CL removes all internal usage of the Context object. It is still
accepted as a parameter until we update Dawn, but all usage is removed.

The namer has been removed from the SPIR-V backend with this change and
the emitted names reverted to their non-modified version.

Change-Id: Ie6c550fab1807b558182cd7188ab6450a627f154
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34740
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-12-02 21:17:58 +00:00
dan sinclair 573d8939f4 [ast] Remove more set methods.
This CL updates the SPIRV-Reader to not require set methods for various
AST expressions.

Change-Id: Ieb9a8fcc1746d3051e5b663559127ca63b45a388
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34642
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-12-02 19:13:48 +00:00
Ben Clayton c15d0a73ee Unrevert "[ast] Remove unused constructors and setters".
Hopefully the trybot issue is now resolved.

This reverts commit 5792783e72,
unreverting commit 4d28b27935.

Change-Id: I2855bf17c5025a3d349e7fce16fdca342517aad3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34564
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 18:48:58 +00:00
Austin Eng 41083cbca4 spirv-reader: Fix bug with passing stack-allocated variable
When handling OpCompositeExtract, the SPIRV reader uses a
stack-allocated U32 type instead of one heap allocated by the
type manager. This causes type determination later to dereference
a garbage address.

Change-Id: I7d60b6dbf8310e53565d7db47eac4dd92b1bbfa0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34684
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
2020-12-02 16:30:38 +00:00
Ben Clayton f8971ae74d Fixup all doxygen tags
We've been using |blah| in various places to markup code, however this is not doxygen markup. So instead:

* If the code links to a parameter, use `blah`.
* If the code links to a member field, use #blah.
* If the code links to a method use blah().
* If the code is somewhere unlinkable use `blah`.

Change-Id: Idac748a4c2531b5bae77e1a335e3d3ef6fab48b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33787
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-12-02 15:31:08 +00:00
dan sinclair 5792783e72 Revert "[ast] Remove unused constructors and setters."
This reverts commit 4d28b27935.

Reason for revert: Seeing weird build breakage ...

Original change's description:
> [ast] Remove unused constructors and setters.
>
> This CL removes unused default constructors and various set methods
> from the AST classes where they are not longer required.
>
> Change-Id: Ic437911c62d8c9e4354a1fa6bdc8483ce7511daf
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34641
> Auto-Submit: dan sinclair <dsinclair@chromium.org>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: dan sinclair <dsinclair@chromium.org>

TBR=dsinclair@chromium.org,bclayton@google.com

Change-Id: I9d5bf6fd6d47131650c964cad4e17a1cbe86b040
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34682
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 15:18:59 +00:00
dan sinclair 4d28b27935 [ast] Remove unused constructors and setters.
This CL removes unused default constructors and various set methods
from the AST classes where they are not longer required.

Change-Id: Ic437911c62d8c9e4354a1fa6bdc8483ce7511daf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34641
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-02 14:31:38 +00:00
Ben Clayton 1b6a8ce165 Post migration to castable cleanup
Change-Id: I5c47b1736bd850548cb1c9c7a6f69242d8626173
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34460
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-12-01 21:07:27 +00:00
David Neto 782f6a5e3e spirv-reader: support textureLoad
Both OpImageRead and OpImageFetch map to WGSL textureLoad.

Bug: tint:109
Change-Id: I3c99840c2e62c52dcaaf7177773a3c972de90cc1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34425
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-01 20:37:37 +00:00
David Neto 91ad3961df spirv-reader: support textureStore
Fixes: tint:381
Change-Id: I401cebcd94b92365037228e0bd50b67bc8d12ab8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34424
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-12-01 20:33:07 +00:00
dan sinclair 2478ae78bb [wgsl-reader] Remove keywords which aren't in spec.
This CL updates the WGSL-Reader to remove the decoration keywords as
they are no longer reserved in the spec. The old `::` token is removed
as well as namespaces don't exist anymore.

Change-Id: I1dfa16c1d7e4866f6c2f9ea7b4f93a48ff5a23d7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34481
Auto-Submit: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-12-01 20:10:47 +00:00
Ben Clayton f1b0e1ee57 ast/type: Remove Type suffix from all types
They already exist in a `ast::type` namespace, so `ast::type::BlahType` is just stuttering.
This is more important now that Is<> and As<> use the full type name.

Change-Id: I7c661fe58cdc33ba7e9a95c82c996a799786661f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34321
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton acf7643518 Replace Literal::(Is|As)* with Castable
Change-Id: I842483890b369d63c23dba475b6738bffe5cfdbd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34319
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton aedca4288c Replace Variable::(Is|As)* with Castable
Change-Id: I7a49287af079d53cee095fa2243dd21757546b56
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34318
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton d6ae990811 Replace Expression::(Is|As)* with Castable
Change-Id: I6ab98ed8b198f1b3b42ce1f09a6c4f992d65fe95
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34316
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 1d8098ae94 Replace Statement::(Is|As)* with Castable
Change-Id: I5520752a4b5844be0ecac7921616893d123b246a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34315
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 4d3ca7f132 Replace StructMemberDecoration::(Is|As) with Castable
Change-Id: I158194c60a9fe0ea2126ca31a92ad536c92a6388
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34314
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 8a82dcd977 Replace StructDecoration::IsBlock with Castable
Change-Id: I4b053aab610b18f99b72156f92317bc8eaf430b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34313
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 731372f0b4 Replace FunctionDecoration::(Is|As)Workgroup with Castable
Change-Id: Ia365504fd745579b3bd7bef0b6eda73d3164f539
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34312
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 75828dbaee Replace FunctionDecoration::(Is|As)Stage with Castable
Change-Id: Iecb683c4bee29952d5f08d92533918f65e342158
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34311
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton c24ac2720d Replace VariableDecoration::(Is|As)Set with Castable
Change-Id: I9808e31f3842b70b3df9ed0398583e09e4f2ca42
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34310
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 2c1d7d5be7 Replace VariableDecoration::(Is|As)Location with Castable
Change-Id: I3096045fc093f3782401ce8623a18e0bca49b22c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34309
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton c0eb9aeafb Replace VariableDecoration::(Is|As)Builtin with Castable
Change-Id: I49d970301c46cfe29d7b22e18abb443daa0c8073
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34307
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 62d81485dd Replace VariableDecoration::(Is|As)Binding with Castable
Change-Id: Ia13ce42054e5f514eb34f6549da10b22129f9026
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34306
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 864579db3d Replace ArrayDecoration::(Is|As)Stride with Castable
Change-Id: I0a346226996c86a6f976b51f69ae4df32806a797
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34305
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 3958f81fd7 Replace TypeDecoration::(Is|As)Access with Castable
Change-Id: I06a2f663cf56f8bb9a9b05557aef428b2d69e84c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34304
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 370d20a4c6 ast: Remove the now unused Decoration::IsKind() method
And replace the use of`ast::As(Decoration* deco)` with `Castable::As<T>()`.

These were used for dynamic casting, but is now replaced with Castable.

Change-Id: Ie5fe19ad4db4bc4d19f5386d2cfddaaf84b215d0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34302
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton b062bbdce8 Replace TextureType::(Is|As)Sampled with Castable
Change-Id: Id997f118a8ce9f4f7c42bed306368d3f204b6607
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34279
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 1a23756294 Replace TextureType::(Is|As)Storage with Castable
Change-Id: I627304c0b397605f565ae688f2a2b61132c26b9b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34278
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 0441bd1756 Replace TextureType::(Is|As)Multisampled with Castable
Change-Id: I9a0e2ba4c6b0950134cef4b291cd1ba5cae1198c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34277
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 09b8829d8e Replace TextureType::(Is|As)Depth with Castable
Change-Id: I2f1785cec1880f728fbbf0c75762bc957e34ca0a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34276
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 16ec1bb626 Replace Type::(Is|As)Void with Castable
Change-Id: If8a27c69c91a968a40a982c02b9fcaf9481e60b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34275
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 8a083ce9c8 Replace Type::(Is|As)Vector with Castable
Change-Id: Ic838aa783a279d0939a972773206fee2e33c4bff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34274
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton d11ced4765 Replace Type::(Is|As)U32 with Castable
Change-Id: I4999d45950fdffe4345cf0abae1b026244abba1d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34273
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 38409c79dc Replace Type::(Is|As)Texture with Castable
Change-Id: I53bbccc3e1e7b88ad8c201997cf7e2e485ad9c81
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34272
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton d734dd0c10 Replace Type::(Is|As)Struct with Castable
Change-Id: I0bc5645d65d7b53058bda7b343a991a9614741be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34271
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 351128a41e Replace Type::(Is|As)Sampler with Castable
Change-Id: Iaa43e607199e25308ecb121c61bb7a37abff197c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34270
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton c52f4214ad Replace Type::(Is|As)Pointer with Castable
Change-Id: Ic1b82f1ddc61355021a80d8e72f645f830363c62
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34269
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton d8457c15f1 Replace Type::(Is|As)Matrix with Castable
Change-Id: I861aed231604a8bfba1f4cf3659b4863556fc3c4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34268
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 9857f81e94 Replace Type::(Is|As)I32 with Castable
Change-Id: Id130581f72e762bd398a4c1c509cdbe21739e750
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34267
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 75f39be976 Replace Type::(Is|As)F32 with Castable
Change-Id: I75e5a34034360c1d4c96ae0ce293bc6cbfc1c33d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34266
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton f3639b787f Replace Type::(Is|As)Bool with Castable
Change-Id: I60ed33bd9a54b14bb9b35f3cd999a2604c2c4450
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34265
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton af37c4ae83 Replace Type::(Is|As)Array with Castable
Change-Id: I8d9b916f5977121380325d373c4e2f805b691fae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34264
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton 67864267c2 Replace Type::(Is|As)Alias with Castable
Change-Id: I10f1d3d0757661a41b44517d55d6f159aced04ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34263
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
Ben Clayton a8d87788da Replace Type::(Is|As)AccessControl with Castable
Change-Id: I833c92be270236fefd1e77a7a145dede757e93e9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34262
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-30 23:30:58 +00:00
David Neto 21e9204e14 tests: Change name SampledImageCase -> ImageAccessCase
Bug: tint:109
Change-Id: I6f5b1d3cf73fa58ae9f4c37d155199649eb37518
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34423
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-30 23:17:05 +00:00
David Neto 2082beed0f spirv-reader: Add entry point declaration to handle test
Bug: tint:109
Change-Id: I25645944061b8b247eda442b61f4591a9359ec4f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34422
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-30 22:53:25 +00:00
David Neto 386755b1ac spirv-reader: fix SPIR-V types in handle tests
Bug: tint:109
Change-Id: Icb4cbe12334c92a86d1c52a0b3569fb22a1cfc7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34421
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-30 22:48:55 +00:00
David Neto aa212ee81f spirv-reader: sampling depth texture requires unsigned Lod
Fixed: tint:378
Change-Id: I835ee7e9fb63dc68db571091f28fd34287c209b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34201
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-27 19:28:53 +00:00
David Neto 29e7e3b78e spirv-reader: Use better names in handle tests
Change-Id: I461cc6fd3b497e7b56b8004266580b4280c7dc42
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34200
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-27 18:14:53 +00:00
David Neto a8b6f87cca spirv-reader: test texture builtins over arrayed textures
Tested:
 - textureSample
 - textureSampleBias
 - textureSampleLevel
 - textureSampleGrad
 - textureSampleCompare

Fixed: tint:349
Change-Id: Ibb45883b88c8eeec6ba40170f47d78613e150db7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34102
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-27 17:00:03 +00:00
David Neto e5aa390e15 spirv-reader: refactor image access tests
Bug: tint:349
Change-Id: I0cd3dc6d6704f5b636a14542993c39d3f6ea5f59
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34101
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-27 16:46:33 +00:00
David Neto 76e5f17313 spirv-reader: simplify tests
Change-Id: I69b4893d8693310f445bbf9667358d7b09f35728
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34100
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-27 16:43:13 +00:00
David Neto 3f305ac294 spirv-reader: split off last coordinate for arrayed texture access
Also ensure that the number of texture coordinates is exactly
the right number required for the given texture dimension.
I think SPIR-V is looser in this respect.

Assumes coordinates are floating point.

Bug: tint:349
Change-Id: I4512c333fada3647c66f13ef31897b2d73b46cf0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33982
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-27 16:17:03 +00:00
Corentin Wallez 456aad3bce Remove use of recent SPIRV-Tools functionality
reader/spirv/parser_impl.cc was using an overload of a function that's
recently added in SPIRV-Tools so rolling Tint would require rolling
SPIRV-Tools at the same time, which is not currently possible because of
a breaking change in spirv-headers.

Bug: chromium:1153258
Change-Id: I4e8cf87a3f11adbd8b6ef289260c6159faf9580c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34142
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-11-27 15:36:23 +00:00
David Neto 61ec48b99e spirv-reader: refactor swizzle creation
Change-Id: I6a09756026b7cbc436d5f232be9331255615e8c3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34040
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-11-26 17:45:52 +00:00
David Neto 3ec71a63aa spirv-reader: test textureSample with depth texture
Bug: tint:109
Change-Id: Ia13940b521229012a7c73fe0896e6ea75c4b1307
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34020
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2020-11-26 16:58:02 +00:00
Ben Clayton b7b6a3f3f4 Fix linter errors about newlines in lists
Change-Id: I5c2eb4d9beed1e6cf9f0f410da116ae3958589b9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33939
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-26 16:47:32 +00:00
David Neto 77e3318b39 spirv-reader: Support depth-reference sampling
Bug: tint:109
Change-Id: I1e1dcd7c0724124a3a29e94e65856a07c54dd998
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34005
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-26 16:39:32 +00:00
David Neto ddaf59016b spirv-reader: Infer a handle type when needed
Fixed: tint:374
Change-Id: I4785a48d456a6b5ba1fa8c9950b4c72d00853fc9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33981
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-26 15:35:12 +00:00
David Neto 66794eada3 Roll dependencies; spirv-reader: avoid spurious OpLine
Roll third_party/gpuweb-cts/ 2a53a9bd3..abe6e1dd2 (51 commits)

2a53a9bd3d..abe6e1dd26

$ git log 2a53a9bd3..abe6e1dd2 --date=short --no-merges --format='%ad %ae %s'
2020-11-25 corentin Port the robust vertex access tests from GLSL to WGSL (#379)
2020-11-25 corentin Port createRenderPipeline validation tests from GLSL to WGSL (#372)
2020-11-23 kainino iterateCollapsedQueries: don't yield files with no tests (#383)
2020-11-20 kainino Clean trailing whitespace inside shader strings (#382)
2020-11-20 yunchao.he Memory sync test for buffer (#302)
2020-11-20 corentin Port verteState validation tests from GLSL to WGSL (#376)
2020-11-20 corentin Port the setVertexBuffer validation tests from GLSL to WGSL (#375)
2020-11-20 corentin Port the render pass validation tests from GLSL to WGSL (#374)
2020-11-20 corentin Port the validation index access tests from GLSL to WGSL (#373)
2020-11-20 corentin Group and update the dynamic state validation tests. (#307)
2020-11-20 corentin Port the primitive topology tests from GLSL to WGSL (#371)
2020-11-20 corentin Port culling tests from GLSL to WGSL (#370)
2020-11-20 corentin Cleanups in webgpu/api/operation/command_buffer (#369)
2020-11-20 kainino From HackMD plan, part 2: some more validation tests (#368)
2020-11-19 kainino Fix cross-device fence signal tests (cherry-pick) (#366)
2020-11-19 kainino From HackMD plan: manual, stress, web_platform, documentation, and some validation (#364)
2020-11-18 corentin Port basic command_buffer tests from the GLSL branch (#350)
2020-11-17 kainino add src/webgpu as a separate folder in the workspace
2020-11-17 kainino Replace grunt tasks with shell tasks
2020-11-17 kainino Check directory names match validQueryPart
2020-11-17 kainino rename web-platform to web_platform
2020-11-17 2154796+austinEng Remove TexelDataRepresentationImpl.isGPULittleEndian (#357)
2020-11-17 2154796+austinEng Implement texelData for rgb9e5ufloat and add texelData unit tests (#352)
2020-11-17 2154796+austinEng Refactor texture zero init tests and use WGSL (#353)
2020-11-17 corentin Port the renderPass resolve tests from GLSL to WGSL (#351)
2020-11-13 mehmetoguzderin Make comments optional (#348)
2020-11-12 corentin Add gen_wpt_cts_html as an NPM script (#347)
2020-11-11 9856269+sarahM0 [wgsl] Update tests to match spec update: Relaxing void return requirement (#330)
2020-11-11 mehmetoguzderin Check PRs to glsl-dependent (#341)
2020-11-10 kainino Remove travis config from main branch (#336)
2020-11-10 kainino Remove AsyncMutex
2020-11-09 kainino Simplify WPT runtime
2020-11-10 mehmetoguzderin Fix Actions on CI (#334)
2020-11-10 corentin Roll webgpu-types. (#329)
2020-11-10 mehmetoguzderin Add CI on Actions (#331)
2020-11-05 natashalee add create sampler validation test (#327)
2020-11-04 kainino wpt: Don't return promise from async_test
2020-11-04 kainino Allow marking tests as explicitly unimplemented (#319)
2020-11-04 kainino standalone: Don't generate DOM when test finishes (#323)
2020-11-04 kainino standalone: Show only the full query string for a test, and aligned (#324)
2020-11-03 kainino standalone: Replace results JSON textarea with copy button (#322)
2020-11-02 kainino standalone: Lazily-generate DOM subtrees (#321)
2020-10-27 enrico.galli Add API validation tests for compute pass (#308)
2020-10-26 kainino Optimize device pool lookup (#295)
2020-10-23 kainino Remove unneeded @babel/plugin-proposal-class-properties (#313)
2020-10-23 kainino Remove non-test dependence on WebGPU ambient constants (#318)
2020-10-20 kainino Loop to exhaust eventualExpectations (#309)
2020-10-20 dsinclair Update WGSL to new struct syntax. (#316)
2020-10-19 kainino Add support for logical assignment operators (&&= ||=) (#311)
2020-10-19 kainino Update npm dependencies (#310)
2020-10-20 corentin Add validation tests for mapAsync. (#301)

Created with:
  roll-dep third_party/gpuweb-cts

Change-Id: Ibed486c6e02d8df9db7a66c00c4546c46df0c1fc

Roll third_party/spirv-tools/ 7e1825a59..2c458414c (62 commits)

7e1825a596..2c458414c0

$ git log 7e1825a59..2c458414c --date=short --no-merges --format='%ad %ae %s'
2020-11-25 dneto BuildModule: optionally avoid adding new OpLine instructions (#4033)
2020-11-25 dneto Remove prototype for unimplemented method (#4031)
2020-11-25 afdx spirv-fuzz: Fix facts arising from CompositeConstruct (#4034)
2020-11-24 afdx spirv-fuzz: Do not flatten conditionals that create synonyms (#4030)
2020-11-23 dneto Update MeshShadingNV dependencies (and land Ray tracing updates) (#4028)
2020-11-18 greg Fix buffer oob instrumentation for matrix refs (#4025)
2020-11-13 afdx spirv-opt: Set parent when adding basic block (#4021)
2020-11-13 jaebaek spirv-opt: properly preserve DebugValue indexes operand (#4022)
2020-11-11 dneto Use less stack space when validating Vulkan builtins (#4019)
2020-11-05 46493288+sfricke-samsung spirv-val: Fix SPV_KHR_fragment_shading_rate VUID label (#4014)
2020-11-05 46493288+sfricke-samsung spirv-val: Label Layer and ViewportIndex VUIDs (#4013)
2020-11-05 alanbaker Add dead function elimination to -O (#4015)
2020-11-04 jaebaek Add DebugValue for invisible store in single_store_elim (#4002)
2020-11-04 dnovillo Fix SSA re-writing in the presence of variable pointers. (#4010)
2020-11-04 afdx spirv-fuzz: Fixes to pass management (#4011)
2020-11-03 afdx spirv-fuzz: Add support for reining in rogue fuzzer passes (#3987)
2020-11-03 vasniktel spirv-fuzz: Fix assertion failure in FuzzerPassAddCompositeExtract (#3995)
2020-11-03 vasniktel spirv-fuzz: Fix invalid equation facts (#4009)
2020-11-03 vasniktel spirv-fuzz: Fix bugs in TransformationFlattenConditionalBranch (#4006)
2020-11-03 andreperezmaselco.developer spirv-fuzz: Fix bug related to transformation applicability (#3990)
2020-10-30 jaebaek Temporarily add EmptyPass to prevent glslang from failing (#4004)
2020-10-30 Junda.Liu spirv-opt: Add support to prevent functions from being inlined if they have DontInline flag (#3858)
2020-10-29 jaebaek Propagate OpLine to all applied instructions in spirv-opt (#3951)
2020-10-29 bclayton CMake: Add SPIRV_TOOLS_BUILD_STATIC flag (#3910)
2020-10-29 dneto Avoid copying a ref in a loop (#4000)
2020-10-28 justsid spirv-val: Allow the ViewportIndex and Layer built-ins on SPIR-V 1.5 (#3986)
2020-10-28 dnovillo Simplify logic to decide whether CCP modified the IR (#3997)
2020-10-27 jaebaek Add DebugValue for DebugDecl invisible to value assignment (#3973)
2020-10-26 greg Fix bounds check instrumentation to handle 16-bit values (#3983)
2020-10-23 andreperezmaselco.developer spirv-fuzz: Add expand vector reduction transformation (#3869)
2020-10-23 vasniktel spirv-fuzz: Don't replace irrelevant indices in OpAccessChain (#3988)
2020-10-23 vasniktel spirv-fuzz: Add FuzzerPassAddCompositeExtract (#3904)
2020-10-22 afdx spirv-fuzz: Fix mismatch with shrinker step limit (#3985)
2020-10-22 afdx spirv-fuzz: Fix off-by-one error in replayer (#3982)
2020-10-22 afdx spirv-fuzz: Get order right for OpSelect arguments (#3974)
2020-10-22 afdx spirv-fuzz: Do not add synonym-creating loops in dead blocks (#3975)
2020-10-22 afdx spirv-fuzz: Skip OpTypeSampledImage when propagating up (#3976)
2020-10-22 afdx spirv-fuzz: Pass OpUndef in function call if needed (#3978)
2020-10-22 afdx spirv-fuzz: Fix off-by-one in TransformationCompositeConstruct (#3979)
2020-10-22 afdx spirv-fuzz: Tolerate absent ids in data synonym fact management (#3966)
2020-10-21 afdx spirv-fuzz: Fix to id availability (#3971)
2020-10-21 afdx spirv-fuzz: Fix operand types (#3962)
2020-10-21 8729214+jonahryandavis Update SPIRV-Headers revision in DEPS file (#3961)
2020-10-21 afdx spirv-fuzz: Don't flatten conditional if condition is irrelevant (#3944)
2020-10-21 afdx spirv-fuzz: Do not produce OpPhis of type OpTypeSampledImage (#3964)
2020-10-21 afdx spirv-fuzz: Restrict fuzzer pass to reachable blocks (#3970)
2020-10-21 afdx spirv-fuzz: Handle more types when extending OpPhi instructions (#3969)
2020-10-21 afdx spirv-fuzz: Skip early terminator wrappers when merging returns (#3968)
2020-10-21 afdx spirv-fuzz: Avoid irrelevant constants in synonym-creating loops (#3967)
2020-10-21 afdx spirv-fuzz: Skip dead blocks in FuzzerPassAddOpPhiSynonyms (#3965)
2020-10-21 afdx spirv-fuzz: Avoid the type manager when looking for struct types (#3963)
2020-10-20 afdx spirv-fuzz: Fix to TransformationDuplicateRegionWithSelection (#3941)
2020-10-20 afdx spirv-fuzz: Skip OpFunction when replacing irrelevant ids (#3932)
2020-10-20 afdx spirv-fuzz: Use component-wise selectors when flattening conditional branches (#3921)
2020-10-20 TobyHector Add SPV_EXT_shader_image_int64 (#3852)
2020-10-20 TobyHector Support SPV_KHR_fragment_shading_rate (#3943)
2020-10-19 afdx spirv-val: Fix validation of OpPhi instructions (#3919)
2020-10-19 afdx spirv-fuzz: Avoid void struct member when outlining functions (#3936)
2020-10-19 afdx spirv-fuzz: Do not allow Block-decorated structs when adding parameters (#3931)
2020-10-19 afdx spirv-fuzz: Fix to operand id type (#3937)
2020-10-19 afdx spirv-fuzz: Handle dead blocks in TransformationEquationInstruction (#3933)
2020-10-19 afdx spirv-fuzz: Do not allow sampled image load when flattening conditionals (#3930)

Created with:
  roll-dep third_party/spirv-tools

Change-Id: Ic75967a4b775dfae8b53a679f48bcc8b3f162217

Roll third_party/spirv-headers/ c43a43c7c..104ecc356 (9 commits)

c43a43c7cc..104ecc356c

$ git log c43a43c7c..104ecc356 --date=short --no-merges --format='%ad %ae %s'
2020-11-12 dneto MeshShadingNV enables builtins PrimitiveId, Layer, and ViewportIndex
2020-10-16 dkoch de-alias/reassign OpIgnoreIntersectionKHR/OpTerminateRayKHR
2020-06-29 alele Raytracing and Rayquery updates for final
2020-06-15 alele Updated headers for new trace/executeCallable and acceleration structure cast.
2020-11-04 michael.kinsner Reserve additional loop control bit for Intel extension (NoFusionINTEL) (#175)
2020-11-02 4464295+XAMPPRocky Add EmbarkStudios/rust-gpu to vendor list. (#174)
2020-10-23 john Bump revision to 4, for SPIR-V 1.5.
2020-10-19 TobyHector Add SPV_EXT_shader_image_int64 (#170)
2020-10-19 TobyHector Added SPV_KHR_fragment_shading_rate (#172)

Created with:
  roll-dep third_party/spirv-headers

Change-Id: Ib43e5574d9fc1d2cffdd3a6cf66cbc3a88db2051

Roll third_party/googletest/ 3c95bf552..b1fbd33c0 (30 commits)

3c95bf5524..b1fbd33c06

$ git log 3c95bf552..b1fbd33c0 --date=short --no-merges --format='%ad %ae %s'
2020-11-23 absl-team Googletest export
2020-11-19 absl-team Googletest export
2020-11-13 vlee Initialize TestInfo member is_in_another_shard_ in constructor.
2020-11-12 absl-team Googletest export
2020-11-12 absl-team Googletest export
2020-11-12 absl-team Googletest export
2020-11-11 dmauro Googletest export
2020-11-11 dmauro Googletest export
2020-11-11 dmauro Googletest export
2020-11-11 absl-team Googletest export
2020-11-11 marius.brehler Refactor finding python
2020-11-06 absl-team Googletest export
2020-11-06 absl-team Googletest export
2020-10-29 knut Only save original working directory if death tests are enabled
2020-11-08 hyuk.myeong fix typos
2020-11-06 absl-team Googletest export
2020-11-05 ofats Googletest export
2020-10-27 absl-team Googletest export
2020-10-27 elliott.brossard Add instructions for sanitizer integration
2020-10-26 absl-team Googletest export
2020-10-20 sonzogniarthur Fix typo "definedin in" => "defined in"
2020-10-15 absl-team Googletest export
2020-10-15 absl-team Googletest export
2020-10-07 manavrion Improve FilePath::Normalize method
2020-09-16 hyuk.myeong Remove spaces between Google Test and Google Mock
2020-09-15 hyuk.myeong Add follow-up patch for more natural reading
2020-09-15 hyuk.myeong Apply the reviewed comment
2020-09-15 hyuk.myeong Remove a space
2020-09-15 hyuk.myeong Improve the tutorial that may be confusing
2020-02-17 krystian.kuzniarek remove a duplicated include

Created with:
  roll-dep third_party/googletest

Change-Id: I62335cb23a96218f62c1842e786777d7e8dfe4f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34007
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-25 21:13:17 +00:00
David Neto eb913d3829 spirv-reader: Start emitting sampled image builtins
- Emit (non-depth) sampler variables
- Emit sampled texture variables

- Test emission of textureSample, textureBias, textureLevel

TODO: convert unsigned offset parameter to signed. crbug.com/tint/348
TODO: support arrayed access, where we have to split out the array index
into a separate operand. crbug.com/tint/349
TODO: for explicit-lod sampling, we may have to convert coordinates to
floating point. crbug.com/tint/346

Bug: tint:109
Change-Id: I12558f99473ca234ce0d09a87fc0c2f4730497bc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33342
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-11-25 19:23:17 +00:00
David Neto 1b543c6778 spirv-reader: Add a disassembler helper
This helped me debug a problem.

Change-Id: I665aaa482c6f20d24966f0990bfe4e15cdd82915
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33800
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-24 15:17:46 +00:00
Ben Clayton 1e87fe5517 reader/wgsl: Abort after raising too many errors
Change-Id: I641ee8c2e34e059a02742d06c24f96acecb39cd3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33720
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2020-11-24 15:15:36 +00:00
Ben Clayton fecf10664a Improve error message when suffixing float with f
Fixes: tint:277
Change-Id: I7ec3bb758c7d80c95c6ecd51eebf4144b696bec5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33668
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 20:07:15 +00:00
Ben Clayton 7e4ffa0064 Add create<T>() method to Module for types
Migrate all uses to use this and the new `unique_type<T>()` and `types()` methods.

Remove the `type_mgr()` accessor. `TypeManager` is now an implementation detail of the module, allowing us to unify the allocation of types and nodes (if we so wish).

Fixes: tint:337
Bug: tint:307
Change-Id: I233fa9dc73d60515dd721f02ea7ba089ef7d374f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33667
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 19:58:55 +00:00
Ben Clayton 0fb5168fc7 Move TypeManager from tint::Context to ast::Module
Bug: tint:307
Bug: tint:337
Change-Id: I726cdf89182813ba6f468f8ac35e5d44b22e1e1f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33666
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 19:50:55 +00:00
Ben Clayton 3e67c5dba6 Move type_manager to the ast dir/namespace
First step to moving this to the `ast::Module`.

Also remove a bunch of redundant includes to `type_manager.h` as this is already included in `context.h`

Bug: tint:307
Bug: tint:337
Change-Id: Ic4baffa7b76ddefa29f56f758c25b1003ef40888
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33665
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-11-23 19:30:55 +00:00
Ben Clayton 7f075c2a88 reader/wsgl: Improve error message for missing 'var'
Fixes: tint:295
Change-Id: Id01ad61fa24f14a1d86ca945d941fd27ee1e8f82
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33400
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-20 11:03:04 +00:00
dan sinclair 7214f407dc [wgsl-reader] Add support for read only storage buffers.
This Cl adds the necessary infrastructure to parse the access decoration
for storage buffers.

This CL incorporates changes from bclayton@ from
https://dawn-review.googlesource.com/c/tint/+/33202 and
https://dawn-review.googlesource.com/c/tint/+/33201

Bug: tint:287
Change-Id: I7479f2cf7ab794b24c682b9927c4c68f6d325839
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33161
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: dan sinclair <dsinclair@chromium.org>
2020-11-19 18:55:01 +00:00
David Neto 36d9a061c8 spirv-reader: Rename a test class
Bug: tint:109
Change-Id: I31ce88cc28e38a22cc7f83ad5653109b133d401a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33440
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-19 15:36:11 +00:00
David Neto 3bc06e3099 spirv-reader: Convert handle types
Synthesize Tint types for handle variables and function parameters.

Bug: tint:109
Change-Id: I3c155e03b154c5ebf46e79c96a6e2b054dbca9b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33341
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-19 15:06:31 +00:00
Ben Clayton aa5f23e1ca reader/wgsl: Improve errors for statements outside functions
Fixes: tint:328
Change-Id: I29c35605c2cf546080e28eaa9d983595b4a8d977
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33401
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-19 14:19:31 +00:00
Ben Clayton 2f4096b0d7 Move the ast node ownership from Context to Module
Fixes: tint:335
Change-Id: I128e229daa56d43e7227ecab72269be33b3ee012
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33240
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-18 20:58:20 +00:00
Ben Clayton 627732c408 src/reader tests: Have parse() return a unique_ptr
The reason being that some tests called parse() twice, which will silently destruct the first parser.
Once the `Module` owns the AST nodes, the second call will end up deleting all the AST nodes. Tests would then perform use-after-free for the AST nodes belonging to the first parser / module.
There's no reason why the unique_ptr can't be returned, which is cleaner overall.

Bug: tint:335
Change-Id: I7ff2e9777a7ebeb76702f806294fe4c2c49bd7c9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33241
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-18 19:40:00 +00:00
Ben Clayton 46d9c7745e Fix linter warnings, stdout test spew
Change-Id: I2fed4cf2a052686e2121066588686f05907a169f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33200
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-18 14:31:00 +00:00
David Neto 064882de2c spirv-reader: Register usage for handle vars and func parameters
Bug: tint:109
Change-Id: I03b684dc75bf20b95e0bd38a9c5e7b78836ec7db
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33141
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-18 02:57:49 +00:00
David Neto 62c8f07015 spirv-reader: GetMemoryObjectDeclarationForHandl can return null
It's valid to look for but not find an underlying memory object
declaration.

Bug: tint:109
Change-Id: I7296d79550a50050d2438996dc3e0c8d09a6babd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33140
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-18 02:14:09 +00:00
David Neto bd7ab2cd5f spirv-reader: Add (handle) Usage abstraction
Bug: tint:109
Change-Id: I5cb8f35636c61cf2f837271a51c4753117b288be
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32387
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
2020-11-17 18:32:18 +00:00
David Neto cebde298f9 spirv-reader: add GetMemoryObjectDeclarationForHandle
Bug: tint:109
Change-Id: Ifb437ce9a39db7f92ca081e7ea551a576b0ecb2b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32740
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
2020-11-17 17:59:38 +00:00
David Neto 90f3253645 spirv-reader: pretend handles are void
We convert types of samplers, images, and sampled images entirely
differently, but still find it useful to generalize ParserImpl::ConvertType
to cover them.

Fake it: Make ConvertType return void for them.

Bug: tint:109
Change-Id: I0982eb987d0914db8227bc0fce552989831129b9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33020
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 23:55:19 +00:00
David Neto a0b6796687 spirv-reader: better message for unknown SPIR-V type
Change-Id: I56a314d0c4eb1f1dfdb8804024a5824e5456356c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32940
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 17:35:57 +00:00
David Neto df2d92d5bb spirv-reader: add conversions for image Dim and Format
Change-Id: I9ad499aaa4683ce9a3ed702f21babaf24a15a8e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32741
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:44:17 +00:00
Ben Clayton 4bfe461646 Big cleanup now that AST nodes are raw pointers
Remove all redundant std::move()s. I've also removed calls to
std::move() in tests, even if they act as an optimization. This is for
two reasons:
(a) Performance is not important for testing, and this helps with
    readability.
(b) A whole bunch tests were relying on std::move() clearing vectors so
    they can be repopulated and used again. This is undefined behavior:

> Objects of types defined in the C++ standard library may be moved from
> (12.8). Move operations may be explicitly specified or implicitly
> generated. Unless otherwise specified, such moved-from objects shall
> be placed in a valid but unspecified state.

All of these UB cases have been fixed.

Removed all duplicate variables left over from:
  `auto* foo_ptr = foo.get()`
which became:
  `auto* foo_ptr = foo`

Bug: tint:322
Change-Id: Ibd08a2379671382320fd4d8da296ccc6a378b8af
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32900
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:41:47 +00:00
Ben Clayton b053acf796 Replace use of std::unique_ptr<T> with T* for AST nodes
This is a minimal effort to fix up the code. There's substantial code
cleanup which can now be done, which is done in the next change.

Bug: tint:322
Change-Id: Iafcf5e814837d9534889e8c21333de4931a19cfa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32864
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 16:31:07 +00:00
Ben Clayton f65799e7da reader/wgsl: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I281fe91864a98365db5ccd40e264d042e6476172
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32861
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-16 16:11:19 +00:00
Ben Clayton 307919dba9 reader/spirv: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but
will be later replaced with a function that returns a raw pointer,
and owned by the context.

Bug: tint:322
Change-Id: I72558482c4b6aff7a655087ee010b3e16b006192
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32860
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 15:21:07 +00:00
Ben Clayton eeac0c5f63 ast: Remove no-arg constructor for ast::IfStatement
In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: I36a1cf55c31a1dabccde272b2be415f98c16b18f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32677
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-16 15:15:37 +00:00
dan sinclair 80598edf78 [ast] Add the result_type into the AST dump
This CL adds the result_type type_name into the AST dump if available.

Bug: tint:310, tint:308
Change-Id: Iea678fd4f7a2dadbfca86f29043c75459c421cb3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32780
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-16 14:46:27 +00:00
Ben Clayton 4ad0019df0 ast: Remove no-arg constructor for ast::CastStatement
In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: I2a571d0a4727d6dc3d6c38e8b6602e131292f49c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32676
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-16 14:25:27 +00:00
Ben Clayton 6a788df30e ast: Remove no-arg constructor for ast::LoopStatement
In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: I3db9b3c037896f07b84b14b7b8d4da0f066b69b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32679
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-14 09:52:25 +00:00
Ben Clayton b29b09fba6 ast: Add body parameter to ast::Function constructors
In a near-future change, AST nodes, such as ast::BlockStatement will no longer
be std::unique_ptrs, and will have to be constructed and owned by an external
class. This means AST nodes can no longer allocate default child nodes.

Bug: tint:322
Change-Id: Iddb5605b9bc0de80ad2710ced0e429f89410af2f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32675
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-14 01:13:04 +00:00
Ben Clayton 6f58546193 ast: Have all AST types derive from ast::Node
A common base class is required to move from std::unique_ptr<> to raw pointers for AST types.

Also unifies a bunch of similar APIs.

Bug: tint:322
Change-Id: If829f8c3f22069adf62751365f1f1eeb646aba08
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32660
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-13 21:43:58 +00:00
Ben Clayton af8091e353 wsgl parser: support multiple error messages
Use synchronization tokens to ensure the parser can resynchronize on error.

Bug: tint:282
Change-Id: I8bb033f8a723eb8f2bc029e1ffc8350174c964e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32284
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 18:44:36 +00:00
Sarah Mashayekhi ef486bf0e4 remove redundant std::move to fix clang errors
Change-Id: I86be320a3f3ac7855460341d4570bc7df715243a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32381
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-11-11 16:40:05 +00:00
Ben Clayton 1bbafa3445 wsgl parser: Tweak top-level unexpected token error message
I feel this reads better.

Bug: tint:282
Change-Id: I04fe42a0347ea050e93e5cf5ccae7259bc79bb58
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32283
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 14:16:45 +00:00
Ben Clayton b707258c8f wsgl parser: Fix tests that have multiple errors
A number of tests check the first encountered error is correct.
As the parser currently aborts after the first error, later errors are ignored.

Once the parser supports resynchronization, we'll emit multiple error messages, and these tests will start to fail. Fix them now.

Bug: tint:282
Change-Id: If8d0c41f030c652500b2e3b7284297b7a448d23e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32282
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 14:15:05 +00:00
Ben Clayton 54af8746ae wsgl parser: refactor statements()
Split out statments that are non-block (non-loops, etc) into a separate function.

These all end with a semi-colon, which is important for resynchronization on errors (coming up in another change).

Bug: tint:282
Change-Id: I0e58c4938f2bbe859dc6ffb8dcd45c8cf26101da
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32281
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 14:11:55 +00:00
Ben Clayton 00bc8ba88c wsgl parser: add expect_lt_gt_block(), use it
Reduces code, paves the way for multiple errors with resynchronization points.

Bug: tint:282
Change-Id: I68018ea8cabe4ec347afa21d1220126d6348d3d1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32280
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-11 14:10:25 +00:00
David Neto a4f49d91dc spirv-reader: support OpDot, OpOuterProduct
Change-Id: I39f2369572a340be1c4c7c6e4a2c8e0e9347d792
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32200
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-11-11 13:59:24 +00:00
Ben Clayton 0573714bfd wsgl parser: Have Expect & Maybe operator-> deref
For values of type T* and std::unique_ptr<T>.

This allows us to replace all occurances of `res.value->member` with: `res->member`, which also asserts that `res` is not in an error state.

Brings the verbosity back down to pre-expect and pre-maybe levels.

Bug: tint:282
Change-Id: Ib00018affca53ac5e71ee2140e7e0cd607b83715
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32141
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 20:44:34 +00:00
Ben Clayton ab5dfee240 wsgl parser: Add ParserImpl::Maybe<T>
And use it for the non-ParserImpl::expect_xxx() methods.

Another step towards supporting multiple error messages, as the caller can now test to see if the specific call errored, or didn't match, instead of using a global error state.

Makes reading the control flow conditionals a bit easier too.

Change-Id: Ie8627b8499ec9079167965da2a566401cd6bd903
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32102
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 19:52:24 +00:00
Ben Clayton 653c4042e2 wsgl parser: Add ParserImpl::Expect<T>
And use it for the ParserImpl::expect_xxx() methods.

This is the first step towards supporting multiple error messages, as
the caller can now test to see if the specific call errored, instead of
using a global error state.

Also cleans up a bunch of code.

Bug: tint:282

Change-Id: I5e39fc33bd1e16620cee80d27fa728bc2af3387e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32101
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 19:39:34 +00:00
Ben Clayton f2e91857e1 wsgl parser: Migrate more code to use expect & match
Reduces code. Keeps things more consistent.

Bug: tint:282
Change-Id: Iff280880eb033fbcee4c6095c2da2d4af06835b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32103
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 19:19:44 +00:00
Ben Clayton d60f0feee4 wsgl parser: expect for storage_class
All the call sites of `storage_class()` add their own error handling, so transform this into `expect_storage_class()`.

Also makes error messages more consistent.

Bug: tint:282
Change-Id: I5131acd84f91fc7494ed6b90965853b7d0fc37f0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32104
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 18:45:53 +00:00
Ben Clayton b8df12042a wsgl parser: expect for variable_ident_decl
All the call sites of `variable_ident_decl()` add their own error handling, so transform this into `expect_variable_ident_decl()`.

Also makes error messages more consistent.

Bug: tint:282
Change-Id: I0b5ac984018ba78896ddec0320636f5b5c4ad0b2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32100
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-09 18:41:23 +00:00
Ben Clayton cd477e6b7b wsgl parser: Remove pointless nullptr checks
The `expect_` prefixes now clearly indicate when a method will internally error, or produce a valid AST object.

Verified by code coverage.

Bug: tint:282
Change-Id: Icbdae9db02bd48c69aec010a4f8fdc5a496125f8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32002
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-09 15:58:42 +00:00
Ben Clayton 7b750dc733 wsgl parser: Prefix methods with `expect_`
... for those that will internally error if the grammar does not match,
otherwise will always return a valid AST object.

This helps identify whether the caller is expected to error or not.

Bug: tint:282
Change-Id: Ied94f717526a63033f2e6c9e94fca43dbf0b8f05
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32001
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-09 15:49:33 +00:00
dan sinclair eff1fb88fc [wgsl-reader][wgsl-writer] Update storage texture type name.
This Cl updates the storage textures to have `storage` in the name. So,
`texture_ro_1d` -> `texture_storage_ro_1d`

Bug: tint:286
Change-Id: I0a9ea02f15de2681d64e272cb42be51a940b6a13
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31840
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-11-04 22:19:33 +00:00
Ben Clayton 88dc2a4895 wsgl parser: Unify logic for all decorations
Parse all decorations with the same function, and create a
`ast::DecorationList`. Once the parser has progressed to the consumer of
the decorations, we attempt to downcast these to the required type,
erroring if they're the wrong kind.

While the error message could be improved further, this greatly reduces
the headscratching around crbug.com/tint/291.

Also knocks another 223 lines off parser_impl.cc.

Bug: tint:291
Bug: tint:282
Change-Id: I7506faeb56d876e5446d900c7c134669a9db6409
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31660
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:55:31 +00:00
Ben Clayton 786bc92002 wsgl parser: Add expect_block(), use it
`expect_block()` takes a start and end token, along with a function to parse a lexical block body.

This reduces code, keeps error messages consistent, and also gives us a future place to try resynchronising the parser so we can have more than one error emitted.

`expect_paren_block()` and `expect_brace_block()` are convenience helpers for providing the start and end tokens for common block types.

Bug: tint:282
Change-Id: I432a0301727b131a6fce875687b952dfc6889a4b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31736
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:08:51 +00:00
Ben Clayton b8791a5129 wsgl parser: Add expect_builtin()
Mirrors expect_pipeline_stage()

Bug: tint:282
Change-Id: I413c87b3684c1f5cfec0c4acd7d3a5160d4b24a9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31735
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:06:21 +00:00
Ben Clayton 32ba9b6722 wsgl parser: pipeline_stage() -> expect_pipeline_stage()
The only place that calls `pipeline_stage()` expects a stage to exist, so follow the `expect_` pattern.

Bug: tint:282
Change-Id: Ie18d24ed25a5f882e66a8e553e53b4fb52dcf6fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31734
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 20:00:31 +00:00
Ben Clayton 53e619f7e9 wsgl parser: Use match() for more trivial patterns
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: I75ac50ef4a2435cfd42e95e851fa1f3524d1dd63
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31733
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-04 19:11:41 +00:00
dan sinclair a7e1492a6a [wgsl-reader][wgsl-writer] Support new sampled texture syntax.
This CL updates Tint to support the `texture_1d` format for sampled
textures. This is alongside the old `texture_sampled_1d` to allow
migration time.

The WGSL writer will always output the new form when converting to WGSL.

Bug: tint:286
Change-Id: I96f0308ad3c28ade96bcab7e24aa0b405e3c4f05
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31380
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-11-04 19:03:21 +00:00
Ben Clayton 4ce7a93202 wsgl parser: Add optional Source* out params
... to match() and expect_ident().

The uses of these two functions frequently want to know the souce of the matched token.

Bug: tint:282
Change-Id: I5279fc2e0834f48d419c6d8c9888189f6212c44a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31732
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 18:39:41 +00:00
Ben Clayton 0371cc4a8d wsgl parser: Use expect_ident()
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Id6e219222a5967bb4b6d67e54816f669c38d0c19
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31731
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-04 16:34:10 +00:00
Ben Clayton 443039a58f wsgl parser: Use expect() for call r-parenthesis
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Ibbbb98bb6f080dd338af7de415c6e86298d910e3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31730
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 15:48:20 +00:00
Ben Clayton 67c37197d6 wsgl parser: Use expect_[nonzero_]uint()
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: If89265dfe4356468d610dab931c906aa3260ce5a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31728
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:27:51 +00:00
Ben Clayton 0358d1bc1b wsgl parser: Use expect() for parenthesis checks
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Ie5059599ed538bc589d594d7f16aa3db6774110b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31727
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:25:21 +00:00
Ben Clayton 5c58a06515 wsgl parser: Use match() for trivial patterns
Replace uses of peek, test, return-or-next with match().
Reduces code.

Bug: tint:282
Change-Id: I5e53601746e78efd007773cfea7109483c5e1630
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31726
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:21:51 +00:00
Ben Clayton f7fc63b8e3 wsgl parser: Use expect() for semicolon checks
Keeps error message consistent. Reduces code.

Bug: tint:282
Change-Id: Ifddb63b65d44427e0680bb25837fcb24ca854eb0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31725
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:17:51 +00:00
Ben Clayton d70f251188 wsgl parser: Add match() and expect() helpers
These will be used to simplify common parser patterns.

Bug: tint:282
Change-Id: Ia281b9aa66b98f4afc726e876fe8aeae5ff4f12c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31724
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-04 14:14:40 +00:00
Ben Clayton 88cd156fd9 wgsl parser: Replace set_error() with add_error()
Have slightly different overloads.

Long term we will want to be able to emit more than one error in a single parse.

Bug: tint:282
Bug: tint:291
Change-Id: Ide61c6ca75d45065e917b8fa16a097048397e31b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31723
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-04 02:23:10 +00:00
Ben Clayton 34a2eb1999 Add Source parameter to decoration constructors
Once a `Decoration` has been parsed, it'll be placed into a `DecorationList` and validated later in the parse. In order to create error diagnostics that refer back to the decoration, we need to know its source.

Bug: tint:282
Bug: tint:291
Change-Id: I38de708adbd041601b61d7e0a4d0402e9a2fe526
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31722
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 21:48:20 +00:00
Ben Clayton 35298800a6 ast: Have all decorations derive from base class
This is the first step in unifying the way decorations are parsed - i.e. instead of parsing decorations in different ways based on the predicted grammar that follows, we can parse decorations blocks in a unified way, then later verify what we have is as expected.

`StructDecoration` has been transformed from an `enum class` to a proper class so it can derive from `Decoration`.

Bug: tint:282
Bug: tint:291
Change-Id: Iaf12d266068d03edf695acdf2cd21e6cc3ea8eb3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31663
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-03 21:40:20 +00:00
dan sinclair d5fd7e02ba Fixup lint errors.
This CL fixes up the various lint errors.

Change-Id: If4d3077b55aadec33980452c43917194d803fac6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31680
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-03 16:26:09 +00:00
Ben Clayton de6938789c Add test for bad function attribute
This test reproduces the unhelpful error message described in tint:291.

Bug: tint:291
Change-Id: Ie93cc59d981691981ba978b690d11c93dfe46ae0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31571
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 15:33:19 +00:00
Ben Clayton d59a5da9e5 Have tint executable use the diagnostic printer
Will now print with better formatting and colors on terminals that support it.

Bug: tint:282
Change-Id: Ibff341cb1dc2dcbda6fa0d72e24fdcb172990138
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31570
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-03 13:15:19 +00:00
Ben Clayton ecea5c8aec Make Formatter a non-interface
I had originally created `Formatter` as an interface as I was intending to implement this differently for linux and windows (for terminal coloring).

Color printing is instead implemented by the `Printer` interface / PIMPL classes.

Replace the multi-boolean constructor with a `Style` struct, as this will make life easier when we want to add / remove flags.

Bug: tint:282
Change-Id: I630073ed7a76c023348b66e8a8517b00b2b6a0d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31569
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 21:16:38 +00:00
Ben Clayton 2d89d98fe1 Fix all doxygen warnings
Bug: tint:282
Change-Id: I6c243c30f4477bb972dc737c8b3ff9cc2e0a91f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31568
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-02 18:02:18 +00:00
Ben Clayton cd5e4a8083 Remove Parser constructors that take a string
... for the content. Everything should be using a `Source::File*` now.

Bug: tint:282
Change-Id: I9bebb94995a946a5919ba6503f2b0ee2058f0fb1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31482
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-11-02 17:55:18 +00:00
Ben Clayton 3d54f13613 Use the new diagnostics for wgsl the parser
Keep the `ParserImpl::error()` format identical to the old error style for now.
Use the explicit `ParserImpl::diagnostics()` method for the error message tests, updating the tests to match the new, improved output.

Bug: tint:282
Change-Id: Ia7e1237170f0f5203a8cfa256322df29e90e2791
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31481
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:56:28 +00:00
David Neto 0a06243a70 spirv-reader: support scalar spec constants
Translate OpSpecConstantTrue, OpSpecConstantFalse, and OpSpecConstant.
The latter only can be used with integer or float scalars.

If the constant has a SpecId decoration, then generate a module-scope
decorated constant.  Otherwise generate a module-scope constant without
decorations.

Register the ID so we know to use the declared const identifier in
expressions later in the module.

Bug: tint:156
Change-Id: Icd6e9b60225ced7ee99963c4f85cec1eb0e3ae6b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31541
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:44:27 +00:00
Ben Clayton 580d6c7f3e Produce end ranges for tokens and AST nodes
This includes a couple of position fixes in `lexer.cc`.

The source for identifiers (vars, params, etc) now refer to the identifier, not the first token of the construct.

Bug: tint:282
Change-Id: I58cb8422a4af1c7dc5f84431fd7f06b823b514c5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31444
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:25:18 +00:00
Ben Clayton a3bcde2c10 Rm line() & column() from wsgl::Token & ast::Node
Use `source().range.begin.line` and `source().range.begin.column` instead.

Bug: tint:282
Change-Id: I6c9bf8766d6db2c9d8e7e1b8bafb2eea93e065d8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31441
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:17:50 +00:00
Ben Clayton fc5a9cfaf7 Remove tint::Source(size_t, size_t) constructor
This was a temporary overload to break up the changes into smaller chunks.
Change all call sites to use one of the other constructors.

Bug: tint:282
Change-Id: I500fe9700d22f72312827808caa22f7feef7b294
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31440
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-11-02 15:07:47 +00:00
David Neto 74023424da Remove stale TODO
Change-Id: I1b7dbbc0290c48309c9cbf00a432e3beccd27bcf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31540
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-11-02 14:56:47 +00:00
Ben Clayton 5bee67fced Add File & Range information to tint::Source
This is the first step in improving the error messages produced while parsing.

The `line` and `column` information of `Source` has been moved to `Source::Location`.

`Source::Range` has been added that contains a `Location` interval - allowing error messages to highlight the full region of the error.

The `File` information provides an optional file path, and pre-splits the content into lines. These lines can be used to print the full line containing an error.

This CL contains a few temporary changes that help split up this work, and to ease integration with Tint.

Bug: tint:282
Change-Id: I7aa501b0a9631f286e8e93fd7396bdbe38175727
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31420
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-10-30 20:44:53 +00:00
Ben Clayton 5d40a5621b Add ParserImplTestWithParam to reduce boilerplate
There were a number of places where we were declaring classes derived from `testing::TestWithParam<T>` and then adding the same `parser()` helper logic.

Move this common logic down to a new `ParserImplTestWithParam<T>` class, and derive from that instead.

Removes a whole bunch of copy-pasta.

Change-Id: I8f308b77817fd6327c045d2fdee4462b7f32897a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31401
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-29 19:19:34 +00:00
David Neto 6857ed0b0b spirv-reader: apply access control to storage buffers
- Apply the AccessControlType wrappar around the struct type for any
  variable in the StorageBuffer storage class.
- Drop the NonWritable member decorations for the struct type.

Bug: tint:108
Change-Id: I6496c8c3e8b5d92b2ed0071385915d2b8065a80d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31020
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-29 14:36:22 +00:00
dan sinclair c55fc39acb [ast] Unify the access control types.
This CL merges the StorageAccess enum with the AccessControl enum. The
enum is moved up to src/ast and placed in its own file for clarity.

Change-Id: I95a905a399b5d2e046ea1ea429b35f2064510c2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31242
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-29 13:36:32 +00:00
Ben Clayton 4dd5665502 Add tests for all reachable parser errors
These are _mostly_ covered in the over various test files, but unlike those, these new tests always parse from the root translation unit.

These new tests also use a new testing class which may be extended to verify error output for different error styles (verbosity, colors, etc).

Change-Id: I105488f9b16d90279af4cc418a1c845b6e239e9e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31263
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-29 13:05:52 +00:00
dan sinclair 512ecc2762 Rename unwrap helpers.
With the addition of the AccessControlType we want to look through the
access control as well as the aliases as we work through the type tree.
This CL renames UnwrapAliasesIfNeeded to be UnwrapIfNeeded and
UnwrapAliasPtrAlias to UnwrapAll.

Change-Id: I5b027919c3143a89be24c4d87b8106f70358c03b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31104
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-28 20:32:22 +00:00
Ben Clayton c23a5652bd Fix a couple of typos found in parser_impl.cc
Change-Id: Ice4047838ad5c5e48803d8a529f3ca24d2ce77c5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31262
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2020-10-28 20:18:22 +00:00
Ryan Harrison 70a3f152f2 Ran 'git cl format' over repo, found some nits
Change-Id: I5774e4cfc8a570522ac6533d69b5b87f7e5e0b6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31081
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-27 18:14:29 +00:00
David Neto f81c1081ea wgsl-reader: treat function formal params as const
They should only be singly-assigned.

This is required because consts can hold pointers, but
var's cannot.  And we need to support pointer arguments.

Bug: tint:275
Change-Id: I00a58734725bd08d40df71c736854a93c364a33c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30923
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-23 23:39:25 +00:00
David Neto 9ab6e8b9eb spirv-reader: treat function parameters as const declarations
Change-Id: I5e5f35be15737c6dc46bb2e9dc1319f7c403eab8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30921
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-10-23 18:19:10 +00:00
David Neto e6fda61ef0 ast::Variable dumping now indicates is_const
If is_const is true, then dump VariableConst{...

For ast::DecoratedVariable, dump "DecoratedVariableConst{..."
when it's const.

Change-Id: I8383e5bc989e4ee20e3a5812f346d5f9a7990dbb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30920
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-10-23 17:45:50 +00:00
dan sinclair 0ce0704741 Remove type alias struct variant.
This CL removes the `type IDENT = struct` format in favour of the
`struct IDENT` variant.

Bug: tint:175
Change-Id: I4fde8012fd07f811cd0bd80445198f6bbc92b720
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30661
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-10-21 19:15:20 +00:00
dan sinclair 7156d3e314 [wgsl-reader] Add parsing of named structs.
This CL adds the parsing of structs with names. The parsing of type
aliased structs remains to allow for migration to the new system. The
named struct format is always emitted.

Bug: tint:175
Change-Id: Ic0579dedbd2dd0edc7dfd30bc2ec02972091e718
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30341
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-19 15:31:47 +00:00
dan sinclair 95dc655bf8 [ast] Change module dump order.
This CL changes the AST dumping order to emit alias types before global
variables. This makes the output easier to read as the types come before
the usages.

Bug: tint:175
Change-Id: Ib7325384b910472e89d6d01853503be989ce4210
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30281
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-15 18:04:44 +00:00
dan sinclair 481ecff293 [ast] Require StructType to have a name
This CL moves the StructType name into the constructor of the struct
type instead of receiving through an accessor. The |set_name| accessor
is removed as it should not be needed anymore. All call sites have been
updated.

The vertex pulling transform was fixed to correctly register an alias
for the structure being created so it will be emitted.

Bug: tint:175
Change-Id: I8802931d9bdbc6c2f12982eea9032931939d195c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30280
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-10-15 17:54:13 +00:00
dan sinclair c169506c9e [wgsl-reader] Allow global variable decorations to have multiple blocks.
This CL updates the WGSL parser to allow global variable  decorations
to accept multiple blocks.

Bug: tint:240
Change-Id: Iaf8f794d285d87af6e2ff8c93e34d88331eedccb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29840
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-10-08 19:40:15 +00:00
dan sinclair eb5d3e147d [wgsl-reader] Allow array decorations to have multiple blocks.
This CL updates the WGSL parser to allow array decorations to accept
multiple blocks. The stride decoration on arrays was turned into a
proper decoration object instead of just storing the stride directly.

Bug: tint:240
Change-Id: I6cdc7400d8847e3e043b846ea5c9f86cb795cf86
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29780
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 19:34:25 +00:00
dan sinclair 71d69e5ed3 Update struct member decorations to allow multiple blocks.
This CL updates the struct member decoration parsing to allow multiple
blocks of decorations.

Bug: tint:240
Change-Id: I97293ef30333f63c33bbc6e728dba11abc020c7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29280
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 19:17:45 +00:00
dan sinclair 1a63c49b4e Update structs to allow multiple decorations
This CL updates to match the spec change allowing multiple struct
decorations.

Bug: tint:240
Change-Id: Id859c6a331c67c46597fc3c70de06d6cc0f486ec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29260
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-10-08 18:33:25 +00:00
dan sinclair 3c02592718 Remove cast operator.
This CL removes the cast operator and converts the tests over to using
type constructors.

Bug: tint:241
Change-Id: I2526acb61f5624b2e1c068612a2ddcc748c92aed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28860
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-24 14:38:44 +00:00
dan sinclair a7d498e060 Rename 'as' to 'bitcast'
This CL updates Tint to use 'bitcast' instead of 'as' for the OpBitcast
conversions.

Bug: tint:241
Change-Id: I53a80de10421b2d9cc009527eebe5ff07e1285c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28801
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-22 22:07:13 +00:00
dan sinclair b4fee2f824 Update builtin methods.
This CL removes the import mechanism, the identifier paths and updates
all of the standard library methods to be builtins.

Bug: tint:242
Change-Id: If09b98a155ae49ced3986ba2c9b517a060693006
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28720
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-09-22 19:42:13 +00:00
dan sinclair 5f8126271d Remove EntryPoint.
This CL removes the EntryPoint node and transitions everything to the
stage decoration.

Change-Id: Ib2840155905c8fa60ff35870f0c4b6705efb73ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28705
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-22 14:53:03 +00:00
dan sinclair de2a019a7f [spirv-reader] Emit StageDecoration when building the functions
This CL adds the emission of StageDecoration to entry point functions.
EntryPoint nodes are still emitted. We duplicate the function emission
if there are multiple entry points pointing to the same function.

Change-Id: Icb48a063f5c6a30948bbe2c37c7fce7431af5864
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28665
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-22 14:22:12 +00:00
dan sinclair 767ea855ab [wgsl-reader] Parse stage decoration
This CL adds parsing of the stage decoration to the WGSL parser. The
decoration is not hooked up yet so it's effectively ignored.

Change-Id: I8d86c55cee189f993c10b6da31a9c388ba452021
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28664
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-09-21 17:42:10 +00:00
dan sinclair cb907b5bc2 [wgsl-reader] Fix issue with missing open brace for functions.
This Cl fixes the function parsing so the opening brace is required.
This will return an error now. The statement::body_stmt is changed to
make the open paren optional.

Bug: tint:236
Change-Id: I3faee1fd5add19aebcdb86943d6f4190c03d0f7a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28520
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-21 15:55:32 +00:00
dan sinclair d05f93fd8e [wgsl-reader] Add workgroup_size parsing
This CL adds parsing of the `workgroup_size` function decoration.

Change-Id: Ia90efc2c014ac0e1614429280cc903d30cf8171d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28663
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-21 00:37:08 +00:00
dan sinclair 35552f2a48 [wgsl-reader][wgsl-writer] Update variable decorations to new syntax.
This CL updates the variable decorations to require ()'s around
parameters.

Bug: tint:238
Change-Id: I835879f41349756ace553a52fc2d460173e70dce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28583
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-20 23:02:48 +00:00
dan sinclair 077d16d5e1 [wgsl-reader][wgsl-writer] Update array decorations to new syntax.
This CL updates the array decorations to the new syntax requiring ()'s
around parameters.

Bug: tint:238
Change-Id: I5a8b19e302fbd3f78392553d8d1c5e882b900180
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28601
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-20 21:28:18 +00:00
dan sinclair 8b685866cd [wgsl-reader][wgsl-writer] Update struct decorations to new syntax.
This CL updates the parsing of struct decorations to require ()'s around
parameters.

Bug: tint:238
Change-Id: Ia35ca5c260c3c57b5fc95788bd1aef07f75edc39
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28600
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: Sarah Mashayekhi <sarahmashay@google.com>
2020-09-20 19:14:28 +00:00
dan sinclair d3f75ca0e8 Add support for multisampled textures.
This Cl adds the AST, WGSL-Reader and SPIRV-Writer support for the
`texture_multisampled_2d` type.

Bug: tint:237
Change-Id: Ib3eb831227b49f32162801f1e1b4e474774c78b3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28480
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2020-09-17 03:53:04 +00:00
Tomek Ponitka 43759bff1c [wgsl-reader] Adding texture_sampler_types to type_decl
Bug: tint:147
Change-Id: Ib806d5c434e98632a83ad8802a3a0aeea609c8c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28125
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-09-15 18:35:43 +00:00
David Neto 0e70e71a87 [spirv-reader]: entry point names are WGSL identifiers
Bug: tint:233, tint:3
Change-Id: Ib753c47c4a77b852e5065c540da79d8cebe6a100
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28282
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-10 17:01:47 +00:00
Tomek Ponitka bcb6eb0830 [wgsl-reader] Parsing storage texture type
Bug: tint:147
Change-Id: I446786b529e777d709213e100e57cbae78ded75f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28122
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-09-08 16:48:09 +00:00
Tomek Ponitka 03f5e2fc9d [wgsl-reader] Parsing image storage type
Bug: tint:147
Change-Id: I79713b5dfa0a4b219cff7a6bb3c514557cf4f261
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28121
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-09-08 16:38:39 +00:00
David Neto f51a48dc49 [spirv-reader] Set entry point name
Until now, we were only setting the function name.

Bug: tint:3
Change-Id: I6d82f6e9744201a04cc8969013694e2e8304a928
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28080
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2020-09-03 18:52:47 +00:00
Tomek Ponitka fd3ca9ee47 [wgsl-reader] Parsing sampled texture type
Bug: tint:147
Change-Id: I21c864dd63c2003797c78758358ab4134cd8ff31
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28002
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-09-02 15:52:15 +00:00
Tomek Ponitka 4beff41b7d [wgsl-reader] Parsing texture sampler types
Change-Id: I6a29d81deca40e89cf5b8ca95cf0373af3dd16b7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28005
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-09-02 14:16:35 +00:00
Tomek Ponitka cbd1ef8523 [wgsl-reader] Parsing depth texture type
Change-Id: Ie886c85db52b934331abe2d5675d9d0e6cdd7210
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28001
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-09-02 14:06:45 +00:00
Tomek Ponitka c354200889 [wgsl-reader] Parsing sampler type
Change-Id: I58a3218a5d0b7ccbe6422340c94cdf3dc1bdf17a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28000
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-09-02 13:26:15 +00:00
David Neto 7653485162 [spirv-reader] Set some source locations
Set source location on function variable declarations, const
declarations, and most normal instructions.

Bug: tint:3
Change-Id: I469afcdf1b7d8f6d1e64617189a6fa329056737f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27700
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-31 18:52:54 +00:00
David Neto 5a75a174d6 [spirv-reader] Uses in phis count as uses
This is required so we actually emit values that are only used
in phis.

Bug: tint:3, tint:215
Change-Id: I9d957a697839b8d09246905c3f28064f0bc01731
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27701
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-31 14:05:51 +00:00
David Neto c5d65cc917 [spirv-reader] Don't hoist pointers that are already in scope.
Bug: tint:3, tint:213
Change-Id: I79410c670b8690c1f1ea86b7b9427f272a4ebbbb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27720
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-29 16:11:02 +00:00
David Neto 6c2a7b712c [spirv-reader] Track line numbers
If OpLine debug instructions are present, use their line and column
numbers.  Otherwise, use the instruction number as the line number, starting
counting from 1.

Bug: tint:3
Change-Id: Ia46c10732922b80b5737b13af1ef71f4259a3555
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27680
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-28 20:38:02 +00:00
David Neto 25b856aa64 [spirv-reader] Avoid certain hoisting cases
If a definition occurs in the first block of an IfSelection or
SwitchSelection, then it should count as belonging to the scope of the
parent of that if or switch selection.  This prevents some bad hoisting
decisions.

Bug: tint:3, tint:213
Change-Id: I89df5e8cbc163577e19e78c2bf393eb1eec4a0aa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27660
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
2020-08-28 19:58:12 +00:00
David Neto fed63103f5 [spirv-reader] Follow non-canonicalized SPIR-V type for composite extract
Follow the actual SPIR-V type when computing a composite extract
instad of the canonicalized view in the optimizer's type manager.
Do this so we can generate the correct member name for a struct,
rather than using the member name for the other representative
struct type. The optimizer's type canonicalizer is insensitive to
struct member names.

Prompted by tint:213, for which the original case was an
access chain.

Bug: tint:3, tint:213
Change-Id: I8705c7ee655fe47c8b7a3658db524fe18833efdb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27603
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-28 16:28:42 +00:00
David Neto 53b1c39036 [spirv-reader] Follow non-canonicalized SPIR-V type for access chains
Follow the actual SPIR-V type when computing an access chain expression,
instead of the canonicalized view in the optimizer's type manager.
Do this so we can generate the correct member name for a struct,
rather than using the member name for the other representative
struct type. The optimizer's type canonicalizer is insensitive to
struct member names.

Fixes tint:213

Bug: tint:3, tint:213
Change-Id: I88ec42a4cb049b011a59d5522e4cb39bc181a4fb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27602
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-28 15:49:31 +00:00
dan sinclair 46252ec3ba [wgsl-parser] Consume empty struct closing brace.
This CL updates the WGSL parser to consume the closing } of an empty
struct.

Bug: tint:218
Change-Id: I0b17d2178b1b4b7f44fcf007da867db07dc2a6ae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27600
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-27 18:17:10 +00:00
dan sinclair 8d72a2bc4e Add missing doc comments.
This cl adds some missing doc comments.

Change-Id: Ic5452c2f9a40ddcc4642062a338f602632f3e057
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27520
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
2020-08-26 20:38:46 +00:00
dan sinclair 43915bd0a1 Emit structs when emitting the aliases.
This Cl updates the AST dump command to emit struct members after
emitting the type alias.

Change-Id: I5e0c3d8f2cc56525586646c613839c2e014d471f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27320
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2020-08-26 19:09:26 +00:00
dan sinclair deea295fc1 [wgsl-parser] Set max recursion depth on const_expr
The `const_expr` can recurse into itself if there are type declarations
inside the const_expr (e.g. vec2<f32>(f32(1.0), f32(2.0))). Currently
there is no limit on the amount of recursion which can be triggered.

This CL sets a limit of 128 nested type declarations at which point an
error will be emitted.

Bug: chromium:1112144
Change-Id: Ifae45034dc9de35aed78ba8eddf584a46c7a55ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27340
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-25 14:58:33 +00:00
Ryan Harrison a291fc1e7f Ran 'git cl format' over an empty CL
Change-Id: Ied8585a4d266900925a81836db45f7525cd5f628
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27181
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-25 14:55:53 +00:00
Tomek Ponitka 63a5aa7d58 [wgsl-reader] Adding for loops
Implementing ParserImpl::for_stmt(). Also adding
for_stmt and body_stmt to ParserImpl::statement().

Bug: tint:138
Change-Id: Idc3f901648ca115f4d94b3614a940263ef841282
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27261
Commit-Queue: Tomek Ponitka <tommek@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-24 18:22:22 +00:00
Tomek Ponitka 43c2a6c7d4 [wgsl-reader] Adding body_statement to statement grammar
Block statements will now be parsed in ParserImpl::statement()

Change-Id: I28f63d4a53c85c0306c57df545f78b4562c6ea7b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27262
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-08-24 13:43:16 +00:00
Ryan Harrison a532ac55d9 Fix handling of .spvasm inputs
BUG=tint:207

Change-Id: Ic429a909d092423908409678b7256bd88de10a99
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26760
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-08-13 17:33:59 +00:00
David Neto 6eb2a85adf [spirv-reader] Remove support for NumWorkgroups builtin variable
It was removed from WGSL MVP
https://github.com/gpuweb/gpuweb/issues/920

Bug: tint:3
Change-Id: I94a584feec88dda7e310ee5d7fa01e93e26cd31d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25526
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-08-05 21:16:59 +00:00
dan sinclair 753f40b869 Fixup build warnings
Change-Id: I7a61bd4363b01bf186e235bf76e97bd513d2fd12
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26081
Reviewed-by: Ryan Harrison <rharrison@google.com>
2020-07-30 18:18:46 +00:00
dan sinclair c8a85aa5a9 [wgsl-reader] Add stride support.
This CL adds stride support to the WGSL reader.

Bug: tint:178
Change-Id: Id6b5163438e562a371255ad3fb992d0a716543e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26040
Reviewed-by: David Neto <dneto@google.com>
2020-07-30 16:50:25 +00:00
dan sinclair bf4614e252 Update some language usage.
This CL updates a few bits of language to be inline with the Android
respectful code rules [1].

1- https://source.android.com/setup/contribute/respectful-code

Change-Id: Ia35b58d9003df64eeb1e9196c9c194f8955c11c1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25941
Reviewed-by: David Neto <dneto@google.com>
2020-07-29 17:49:01 +00:00
David Neto d35e4e1bbe [spirv-reader] Only support column-major matrices
- drop ColMajor, MatrixStride member decoration
- RowMajor matrix decoration is an error

Bug: tint:3, tint:99, tint:31
Change-Id: I7eb1ec53813a4b1ada971e8725dc91ffdf97bd43
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25920
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-29 16:04:23 +00:00
dan sinclair cfdc5995ec [spirv-reader] Update to create BlockStatements
This CL updates the SPIR-V Reader to create BlockStatements instead of
StatementLists.

Bug: tint:136
Change-Id: I957019446ca00306187de701f86ae3e0dd5c5eb8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25740
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair f751501c35 [wgsl-reader] Update to create BlockStatements
This CL updates the WGSL Reader to create BlockStatements instead of
StatementLists.

Bug: tint:135
Change-Id: Ifda394023553a625dad67be7d4e0dc815292282a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25724
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 37c0970d51 Convert LoopStatement to use BlockStatement.
This CL converts the LoopStatement class to using a BlockStatement
internally. All usages have been updated execept for the two readers.

Bug: tint:130
Change-Id: Ied4b82f0ef49c7b92caa040bcf73050093022df7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25723
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 77040b85d9 Convert IfStatement and ElseStatement to use BlockStatement.
This CL converts the IfStatement and ElseStatement classes to using a
BlockStatement internally. All usages have been updated execept for the
two readers.

Bug: tint:130
Change-Id: I59a5b92f22f35f27f17e005aa9b266f4a2b0ef25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25722
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 7c2fa1e7bc Convert CaseStatement to use BlockStatement.
This CL converts the CaseStatement class to using a BlockStatement
internally. All usages have been updated execept for the two readers.

Bug: tint:130
Change-Id: Idb9114230f7d9eb0f2208af635316edb0a0e8f99
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25721
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 4069f3357d Convert Function to use BlockStatement.
This CL converts the Function class to using a BlockStatement
internally. All usages have been updated execept for the two readers.

Bug: tint:130
Change-Id: I7159cf2d3ed5cb8a34d51fbe848b88f0e5479605
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25720
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
2020-07-27 15:25:00 +00:00
dan sinclair 8f3c6356d4 Remove KillStatement
This CL removes the KillStatement from the AST and replaces all test
usage with DiscardStatement.

Bug: tint:169
Change-Id: Ie68dd3cdd54056f144d10506f05cc1f6903d1cda
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25605
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:33:50 +00:00
dan sinclair 23508f4339 [spirv-reader] Convert from KillStatement to DiscardStatement
This CL changes the SPIRV-Reader to generate DiscardStatements instead
of KillStatements for an OpKill.

Bug: tint:168
Change-Id: Ic4223b614c822c6ad449f61aedaddc9605c42535
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25642
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:33:35 +00:00
dan sinclair f75f2cd22e [wgsl-reader] Add `discard` parsing.
This CL adds parsing of the `discard` keyword to the WGSL reader.

Bug: tint:167
Change-Id: Iff91076a65715131f5f0f9bd1c8b6bf3a37cd3c7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25604
Reviewed-by: David Neto <dneto@google.com>
2020-07-25 14:33:13 +00:00
dan sinclair 095523020a Fixup some doc and compile issues.
Change-Id: I75547e3fb4e1e4be08bde08f0bcfcf7e979791e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25640
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-24 00:11:53 +00:00
Ryan Harrison 7a0b734864 Fix BUILD.gn builds
Change-Id: I4e54b30497e064061baff2dcc205b68db87bee2c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25540
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-22 20:41:12 +00:00
David Neto b6f0299964 [spirv-reader] Support OpAny, OpAll, OpIsInf, OpIsNan
Bug: tint:3, tint:121
Change-Id: I1a6a2d45684c28a0e03ad4b208dc6b2f737da694
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25422
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-22 12:58:31 +00:00
David Neto d71e80b710 [spirv-reader] Add README.md
Bug: tint:3
Change-Id: Ie711f7bdbb870c9f370ce777653884c5942a0622
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25260
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
2020-07-21 17:11:50 +00:00
David Neto 28d0f4b905 [spirv-reader] Support function call returning void
Bug: tint:3, tint:99
Change-Id: I6fe6d06d79115e6b3b0adb800f21c4704795dc15
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25360
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-21 16:08:56 +00:00
dan sinclair fbbc617888 Parse void function call.
This CL updates the WGSL parser to handle a void function call.

Fixes: tint:45
Change-Id: If5b2a4b9e62f0b10e0f2e2e10c0ca2586c5268e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25322
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2020-07-21 15:13:36 +00:00
David Neto 0a56a103be [spirv-reader] Support select over scalars and vectors
Still TODO: OpSelect over arrays and structures, as permitted in SPIR-V 1.4

Bug: tint:3, tint:99
Change-Id: I70f6c8a43ea3339cd715813c6eb0128d66ff0df8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/25301
Reviewed-by: dan sinclair <dsinclair@chromium.org>
2020-07-21 13:36:25 +00:00