Commit Graph

1818 Commits

Author SHA1 Message Date
James Price f8f31a458f Automatically run entry point IO canonicalization
Avoids the need for downstream users to manually run this transform.

Change-Id: I0c63e2fd8b6ad49b752ed1757370e386171481cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47440
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-09 13:50:38 +00:00
Antonio Maiorano 71512e30ca Remove validator.h
With this change, the Validator is fully removed from Tint, including
from it's public API.

Fix: tint:642
Change-Id: Id4867cc3866bb2ea09eff499537d58b938d18f43
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47125
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-09 13:26:38 +00:00
Ben Clayton e2c775f4bb writer/hlsl: Fix storage buffers
Use the new CalculateArrayLength and DecomposeStorageAccess transforms to simplify storage buffer patterns before running the HLSL writer.

The HLSL writer now handles the InternalDecorations for the internal load, store, and buffer-length intrinsics.

GeneratorImpl::EmitStorageBufferAccessor() has now been entirely removed, as all this primitive load / store decomposition performed by DecomposeStorageAccess.

TODOs around runtime arrays have been removed, as this is now handled by CalculateArrayLength.

Bug: tint:185
Bug: tint:683
Change-Id: Ie25a527e7a22da52778c4477cfc22501de558a41
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46878
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-09 13:20:28 +00:00
Ben Clayton 015b9aa93a Add transform::CalculateArrayLength
Used to used to replace calls to arrayLength() with a value calculated from the size of the storage buffer.

Bug: tint:185
Change-Id: If7ddc8dad2ed3d20c1d76b5f48bfd2c7634f96e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46877
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-09 10:28:48 +00:00
Ben Clayton 6d30523a11 Add transform::DecomposeStorageAccess
Used to breakdown storage buffer reads and writes into primitive loads and stores.

Bug: tint:683
Change-Id: I92983deef7485bc1a6a5d9921ec82f8e19b09744
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46876
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-04-09 09:10:38 +00:00
James Price 3c1d4870e3 [inspector] Add support for new entry point IO syntax
Fixed: tint:706
Change-Id: Ia5625a67aaf68665cd003503b6da1bb37c0ff4b1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47282
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-08 22:41:08 +00:00
James Price daf1f1c0a8 Add ProgramBuilder::Param() helpers and use them
Fix some SPIR-V tests that were wrongly expecting parameters to be
loaded from memory as a result of them not being const.

Change-Id: Ieab6f1edd4a4ba6efd226fe190e7a49b309048c5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47281
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-08 22:15:48 +00:00
James Price a12ccb20a0 [ast] Add helpers for searching a decoration list
This is a commonly used pattern.

Change-Id: I698397c93c33db64c53cbe8662186e1976075b80
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47280
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-08 21:53:27 +00:00
Ben Clayton c76ec15b45 reader/wgsl: Add deprecation warning for [[offset]]
Bug: tint:626
Change-Id: I3e1074bbf104d73c3a2f71234ff7821d0481ad1a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47142
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-04-08 18:11:27 +00:00
Ben Clayton 571f2b7363 wgsl: Deprecate 'const' for 'let'
Renamed with:
https://github.com/gpuweb/gpuweb/pull/1574

Bug: tint:699
Change-Id: I4dda868abe4c5bc0cba46bc81d9eb297a0663717
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47141
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-04-08 15:46:17 +00:00
David Neto fae0aa6e72 Add a style guide
Change-Id: I13bf82440cdf5c9268e8cc0d35a1119ebf9a9ed0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/42200
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
2021-04-08 15:10:47 +00:00
David Neto 80767413b8 spirv-reader: fix position calculation of for phi var decl
Fixed: tint:495
Change-Id: I93f1b289eb33c2bda8b661f591a1c8dde775b1ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46220
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Alan Baker <alanbaker@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-04-08 14:51:57 +00:00
Ben Clayton 586fca472d CloneContext: Fix CloneWithoutTransform()
Add tests

Change-Id: I39630336fc3e12ee9484783b5b374b9c3f5587ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47221
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-04-08 14:47:37 +00:00
Ben Clayton 9328d94572 wgsl: Deprecate '-> void' on functions
Was removed with:
https://github.com/gpuweb/gpuweb/pull/1460

Bug: tint:677
Change-Id: If08cb450189c6158561051ef6e8f2439c60bc010
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47140
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-04-08 14:39:47 +00:00
Antonio Maiorano d15391e802 Remove tint's usage of Validator
Also update comments and arch design to remove references to the
Validator.

Bug: tint:642
Change-Id: Ic0b4779ae4712a393ff209014daf25e23f32be6d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47061
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-08 14:08:47 +00:00
Antonio Maiorano 101f463992 Speed up intrinsic table registration
Reserve enough memory for overloads, and avoid copies. Opportunistically
avoid copying Source instances in ProgramBuilder API.

Speeds up runs of test_unittests.exe by about 20% (33s to 26s on my
Windows desktop).

Change-Id: I6ba26043d7750eb1f123e29c53d253614974f960
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47060
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-07 20:35:11 +00:00
Ben Clayton 933d44a2c8 transform/hlsl: Hoist structure constructors to new var
HLSL has some pecular rules around structure constructors.
`S s = S(1,2,3)` is not valid, but `S s = {1,2,3}` is.

This matches the quirkiness with array initializers, so adjust the array
hoisting logic to also support structures.

Fixed: tint:702
Change-Id: Ifdcafd98292715ae2482f72ec06c87842176d270
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46875
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-04-07 17:29:31 +00:00
Antonio Maiorano 8f42be3f60 Delete Validator except public API
Now that all validation has been moved to the Resolver, we can delete
the Validator. This change removes everything except validator.h with
the public no-op API. We can remove this once we remove dependencies on
this public API in Dawn.

Bug: tint:642
Change-Id: I644cd900615509c9cdd57c375c6217a50126e36c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47023
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-07 16:32:01 +00:00
Ben Clayton bebb1cb8f1 writer/hlsl: Fix zero-init of vectors
float3(0.0f) is not legal HLSL

Change-Id: I2fd20e9718f394c896c9515c4c9b88e490b2b758
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46874
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-07 16:30:41 +00:00
Ben Clayton ab26a8fd34 hlsl/writer: Transpose matrices
HLSL's matrices are declared as <type>NxM, where N is the number of
rows and M is the number of columns. Despite HLSL's matrices being
column-major by default, the index operator and constructors actually
operate on row-vectors, where as WGSL operates on column vectors.
To simplify everything we use the transpose of the matrices.

This is the same approach taken by SPIRV-Cross.

Change-Id: I98860e11ff1a68132736980f694b2f68b633ef83
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46873
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-07 15:54:11 +00:00
Ben Clayton 8bd7cc7e88 ast::Variable: Fix nullptr access in info_to_str
With type inference, declared_type_ may be null.
Check it is not null before calling type_name().

Change-Id: I3b7630286b75aa9d021d9cf54eecedc3287a62f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46872
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-04-07 15:32:31 +00:00
Ben Clayton dac5418819 type::Type: fix weird formatting
Change-Id: I12c6836316f30b0924c2bb5a62ee6c168749fa30
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46871
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-04-07 12:48:01 +00:00
Ben Clayton 1b8d9f227b CloneContext: Don't create named symbols from unnamed
Registering a new Symbol with the NameFor() of the source symbol creates
a new *named* symbol. When mixing these with unnamed symbols we can have
collisions.

Update CloneContext::Clone(Symbol) to properly clone unnamed symbols.

Update (most) the transforms to ctx.Clone() the symbols instead of
registering the names directly.

Fix up the tests where the symbol IDs have changed.

Note: We can still have symbol collisions if a program is authored with
identifiers like 'tint_symbol_3'. This will be fixed up in a later
change.

Change-Id: I0ce559644da3d60e1060f2eef185fa55ae284521
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46866
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-07 11:16:01 +00:00
Ben Clayton 3bfb6817df semantic::Struct: Add FindMember
Change-Id: Ie7b76ad8b7dbac1303ed73ba6962e584fed76238
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46628
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-07 08:35:31 +00:00
Ben Clayton f23696ddda BoundArrayAccessors: Don't share AST nodes
Each AST node must be unique.
Having diamonds in the AST causes all sorts of exciting bugs in the resolver and later transforms.

Bug: tint:469
Change-Id: I5dc43fef71a200632b3e8e8add77ec0537b01cd2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46870
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-07 08:09:41 +00:00
Ben Clayton b502fdf82b Add ast::InternalDecoration
An tint-internal decoration used to add metadata between a sanitizer transform and a backend.

Will be used for declaring backend-specific intrinsic calls.

Change-Id: Ia05ba7dada0148de2d490605ba4d15c593075356
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46868
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-07 08:09:21 +00:00
Ben Clayton 86c2cbfb7e Add semantic::VariableUser
Derives from semantic::Expression.
Maps to ast::IdentifierExpressions that resolve to a variable.

Breaks pure-immutability of semantic::Variable, as we have discussed in the past.

Change-Id: I362d4d1ed61291282a60626b84fb15566655fb14
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46627
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-07 08:09:01 +00:00
Antonio Maiorano e93d46fcbc Move remaining Validator tests to Resolver
Bug: tint:642
Change-Id: I0f983d8c0391f4e500562faadf0a621c4edb46ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46942
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-06 20:43:47 +00:00
Antonio Maiorano bfc97945f3 Move entry point validation from Validator to Resolver
Move logic and relevant tests.
Remove validator/validator_decoration_test.cc.

Bug: tint:642
Change-Id: Ie89118a11233931605f18e762274bb2afcaaa460
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46941
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-06 20:41:07 +00:00
Antonio Maiorano bbbb0edec2 Move global var validation from Validator to Resolver
* Moved global variable resolving logic to new function Resolver::GlobalVariable, and moved validation logic there.
* Moved global variable-related tests to resolver tests.
* Fixed many tests that started failing after this change, mainly because many globals were declared with no storage class. I set most of these to "Input".

Bug: tint:642
Change-Id: I0f8ea2091ed2bb3faa358f9497cd884b2994a40f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-06 20:18:57 +00:00
Ben Clayton 4f154a839d writer/hlsl: Fix validation errors
Several tests fail DXC validation.
Many are fixed by specifying the entry point name.

Change-Id: I1c5c0f1f9c057156106334c2e9c0f15906a06813
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46867
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-04-06 18:15:17 +00:00
James Price a2239c64e0 Update Tint samples to new entry point IO syntax
Change-Id: Iadfb311a66b709470740d13884e94702856858b4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46920
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-04-06 18:08:47 +00:00
James Price ca0f51fe45 [spirv-writer] Fix missing symbol clone in entry point IO transform
Fixed: tint:701
Change-Id: Id85e1170c85eedb9f04e5759aff84edc0d1c1453
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46900
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-04-06 17:31:27 +00:00
James Price 68f558f29c [resolver] Add entry point IO validation
Checks the following things:
- Non-struct entry point parameters must have pipeline IO attributes
- Non-struct entry point return type must have a pipeline IO attribute
- Structs used as entry point parameters and return values much have
  pipeline IO attributes on every member
- Structs used as entry point parameters and return values cannot have
  runtime array or nested struct members
- Multiple pipeline IO attributes on a parameter, return type, or
  struct member is not allowed
- Any given builtin and location attribute can only appear once for
  the return type, and across all parameters

Removed tests for nested structs from the SPIR-V transform/backend.

Fixed a couple of other tests with missing pipeline IO attributes.

Fixed: tint:512
Change-Id: I4c48fe24099333c8c7fcd45934c09baa6830883c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46701
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-04-06 15:51:47 +00:00
Antonio Maiorano 09356cc3dc Move VariableDecl validation from Validator to Resolver
Moved tests and fixed now broken tests.

Bug: tint:642
Change-Id: Iaa4483abde101f3963ca20e51c1069b2d64bbb5c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46661
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-06 14:07:07 +00:00
James Price 2f04dc94ce [validator] Remove requirement to have an entry point
The SPIR-V and HLSL sanitizing transforms add an empty one if
necessary.

Fixed: tint:679
Change-Id: Ic98ff3109d7381b1fbc2de68d95d57e15c7a67c0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46700
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-04-01 22:07:37 +00:00
Antonio Maiorano 1fe1a5e641 Validator: remove IsStorable and tests
This function, along with unit tests, already exist on Resolver.

Bug: tint:642
Change-Id: I35fe7ee6dc52a6f58ad6145bd15b071795ac069d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46680
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-01 20:05:07 +00:00
Antonio Maiorano 61dabab673 Validate multiply of invalid vector/matrix sizes
Added tests that test all combos of vec*mat, mat*vec, and mat*mat for 2,
3, and 4 dimensions.

Bug: tint:698
Change-Id: I4a407228261cf8ea2a93bc7077544e5a9244d854
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46660
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-01 19:58:37 +00:00
Antonio Maiorano f1b643ee70 Improve binary expression validation error message
Example:
```
  var a : i32;
  var b : f32;
  if (a == b) {
    return vec4<f32>(0.4, 0.4, 0.8, 1.0);
  }
```

Outputs:
```
error: test7.wgsl:6:9 error: Binary expression operand types are invalid for this operation: i32 equal f32
  if (a == b) {
        ^^
```

Bug: tint:663
Change-Id: Idd2bb5a248b3c7d652483931d7dd58d5123e9ee8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46640
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-01 19:40:37 +00:00
Antonio Maiorano 15c6ed048c Fix binary expression resolving and validation with type aliases
* Fixed resolving logical compares with lhs alias
* Fixed resolving multiply with lhs or rhs alias
* Fixed resolving ops with vecN<alias>and matNxM<alias>
* Fixed validation with lhs or rhs alias
* Fixed spir-v generation with lhs/rhs alias and added missing error
message
* Added tests for all valid binary expressions with lhs, rhs, or both as
alias

Bug: tint:680
Change-Id: I095255a3c63ec20b2e974c6866be9470e7e6ec6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46560
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-04-01 14:59:27 +00:00
Antonio Maiorano c6aa48e4ea CMake: disable "no-used-but-marked-unused" Clang warning
This warning arises when using gtest SCOPED_TRACE. Chromium doesn't
enable -Weverything, which is why the GN build doesn't produce this
warning.

Bug: tint:680
Change-Id: Ie90ea3b9378a1864165bfd889286071d9c0b88c6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46580
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-31 23:39:46 +00:00
Ben Clayton b4275c870e CloneContext: Pass the vector to InsertBefore()
There's usually only ever one vector we want to insert into.
Inserting into *all* vectors that happen to contain the reference object is likely unintended, and is a foot-gun waiting to go off.

Change-Id: I533084ccad102fc998b851fd238fd6bea9299450
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46445
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-03-31 21:00:26 +00:00
Ben Clayton 90f43cf87f Replace all uses of assert() with TINT_ICE macros
Use TINT_ICE() where we have diagnostics, TINT_ASSERT() where we do not.

Change-Id: Ic6e842a7afdd957654c3461e5d03ecec7332e6f9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46444
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-31 20:43:26 +00:00
Ben Clayton dba65b7a34 Add semantic::Statement::Block() for getting the owning BlockStatement
Required special casing the ElseStatement, as this isn't actually owned by a BlockStatement.

Change-Id: Ic33c207598b838a12b865a7694e596b2629c9208
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46443
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-31 20:35:46 +00:00
James Price 285b8b6e75 [hlsl-writer] Use entry point interface canonicalization transform
This replaces the entry point IO component of the HLSL sanitizing
transform, and completes support for the new entry point IO syntax.

Struct emission in the HLSL writer is updated to use the correct
attributes depending on the pipeline stage usage.

Fixed: tint:511
Change-Id: I6a30ed2182ee19b2f25262a30a83685ffcb5ef25
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46521
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-03-31 19:15:06 +00:00
James Price dc8f08a782 [msl-writer] Use entry point interface canonicalization transform
This replaces the entry point IO component of the MSL sanitizing
transform, and completes support for the new entry point IO syntax.

Struct emission in the MSL writer is updated to use the correct
attributes depending on the pipeline stage usage.

Fixed: tint:510
Change-Id: I7ace33568c5a6e1bbf5c90f67b920579ba14be78
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46520
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-03-31 18:42:12 +00:00
James Price 3f985b984d Add a transform for canonicalizing entry point interfaces
After the transform, an entry point's parameters will be aggregated
into a single struct, and its return type will either be a struct or
void. All structs in the module that have entry point IO decorations
will have exactly one pipeline stage usage.

This will be used to sanitize entry points for the MSL and HLSL
generators.

Change-Id: I7d2fcfba961d2e20326086964207747d573b6e05
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46500
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-31 17:44:27 +00:00
Ben Clayton c87ff9c238 Resolver: Move logic ValidateFunction() -> Function()
I inserted this non-validation code in the wrong method.

Change-Id: I43f6d8a0cbf6f0b5f20e453785b141b50d159044
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46442
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-31 17:23:07 +00:00
James Price 5c523f331d [resolver] Apply type storage class uses via return types
Change-Id: I16cf23af7f6a792d22268e6af45c77d4faeb6918
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46460
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-31 15:44:07 +00:00
James Price 494e82dc8a [resolver] Track pipeline stage usages for structs
This will be used by the generators to determine how to handle
location decorations.

Change-Id: Ib0e0ce852a5da3819781b402c5625a440c4c9544
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46400
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-31 15:42:17 +00:00