Commit Graph

1617 Commits

Author SHA1 Message Date
Ben Clayton 6b2fc057c5 Resolver: Check that initializers and assignments are valid
This performs very basic type verification for assignments and variable initializers.

Pulls part of the validation logic out of the Validator into the Resolver.
Involves fixing up a bunch of broken tests.

Bug: tint:642
Fixed: tint:631
Change-Id: Ifbdc139ff7eeab810856e0ba9e3c380c6555ec20
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45281
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-18 21:14:44 +00:00
Ben Clayton 25eef8d2cf s/sharable/shareable
Fixed: tint:660
Change-Id: I5b98597acb771f6b07a16a85d85d8ae5249e495d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45283
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-18 21:03:24 +00:00
Ben Clayton 722b5a2d18 Resolver: Add validation for host-sharable / storage
Fixes a TODO

Bug: tint:60
Change-Id: Ica44d6dbff682374473cacec9d0515e6d3b02f4c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45245
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-18 20:46:24 +00:00
Ben Clayton c98dedf57a Validator: Fix GCC unused variable warning / error
Change-Id: I36e1a86328249abccfde4e6b7712d6e2a9d32c7b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45286
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-18 20:05:34 +00:00
Antonio Maiorano 9970ec63ca Move struct validation from Validator to Resolver
* Moved Validator::ValidateConstructedType, which only validated
structs, to Resolver as ValidateStructure.
* Moved relevant tests to new files, and also updated all failing tests
to validate Source location.
* Fixed other tests that broke now that we're validating structs.

Bug: tint:642
Change-Id: Iefc08ef548f52d8c3798d814d2183c56d1236c2d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45160
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-18 17:59:54 +00:00
Ben Clayton e072465d83 Resolver: Handle AccessControl for storage-class propagation
Fix msl tests that were impacted by this

Change-Id: I00f4280c2f059358d9187babda9e44f2d16b096e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45244
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-18 16:44:24 +00:00
Ben Clayton a63145a923 Resolver::IsStorable() Handle AccessControl types
Also: Clean up tests.
Change-Id: Ib22bd742b4e3cab55ee078d634ea7aee9a5b8d58
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45243
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-18 16:39:54 +00:00
Arman Uguray 097c75ae3e Resolver: Enforce matrix constructor type rules
Added enforcement for matrix constructor type rules according to the
table in https://gpuweb.github.io/gpuweb/wgsl.html#type-constructor-expr.

Fixed: tint:633
Change-Id: I97fc7f558f04780ed03252d94c071af3e0e07e26
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45020
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Arman Uguray <armansito@chromium.org>
2021-03-18 15:43:14 +00:00
Ben Clayton 512bdf1612 Diagnostic: Replace 'info' with 'note'
Change-Id: Icde015422882bad9a1427d5480718c822a28fd6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45242
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-18 14:14:34 +00:00
Corentin Wallez 399b88845c Quickfix for unknown warning in Chromium
Chromium uses clang 13.0 that likely removes the warning while Skia uses
clang 12.0 that still has the warning. Temporarily skip the
-Wno-return-std-move-in-c++11 in Chromium only while Skia changes to not
add warnings to it's third_party dependencies.

Bug: dawn:706
Change-Id: I625f0046204328dcf2cfb1eb9824f8a4a928b8ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45240
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-18 12:27:24 +00:00
Ben Clayton 4f390a196e msl tests: Verify that the structure layout is correct
The Metal programming language is a C++14-based Specification with
extensions and restrictions.

Tint is written in C++14.

Take advantage of the fact that MSL is based on the same language that
Tint is written in, and validate that the field members match what the
C++ compiler expects.

Fixed: tint:650
Change-Id: I352871d6efa3f0a5631e7b986284fb5f1a0b3e9f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45060
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-18 11:08:14 +00:00
Ben Clayton 5907039597 msl: Implement more types for structure layout
Implement layout logic for vectors, matrices and default-stride arrays.

Custom stride arrays are complex, and will be tackled as a followup change.

This change also emits byte offsets for all structure members as comments. This is even emitted for non-storage uses, which can be cleaned up as a followup.

Fixes a whole lot of TINT_ICE() for non-complex WGSL shaders.

Bug: tint:626
Change-Id: I92a78451d29bdb04dbf28862ad22317f27bced60
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44864
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-03-18 10:03:04 +00:00
Ben Clayton a88090b04d Resolver: Track storage class usages of structures
This will be used to validate layout rules, as well as preventing
illegal types from being used in a uniform / storage buffer.

Also: Cleanup logic around VariableDeclStatement
This was spread across 3 places, entirely unnecessarily.

Bug: tint:643
Change-Id: I9d309c3a5dfb5676984f49ce51763a97bcac93bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45125
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-17 22:47:33 +00:00
Ben Clayton 893afdfd2c Resolver: Defer building of semantic::Struct until end
This will allow us to collect up usage information of the structures in a single pass.

Bug: tint:320
Bug: tint:643
Change-Id: Iaa700dc1e287f6df2717c422e66ec453b23b22dc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45123
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-17 22:01:53 +00:00
Ben Clayton ad97343214 Add semantic::Struct::SizeNoPadding
This is the size of the structure without the trailing alignment
padding. This is what the Dawn needs from the Inspector.

Fixed: tint:653
Change-Id: Iaa01ba949e114973e4a33e084fc10ef9e111016c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45120
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-17 21:54:13 +00:00
Ben Clayton 96829ed314 Add Kokoro build configuration files
Bug: tint:652
Change-Id: Ifd9d6f9dde9c01c4c64e9c2bc59395ef049dd54b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44872
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-17 18:52:03 +00:00
Ben Clayton 8b53104c20 Add test/test-all.sh
Checks that all the .wgsl test files actually compile with tint

Change-Id: Iea31f0f58fe0580fca55b07cf3b3ffc24cebcf9d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44870
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2021-03-17 18:49:03 +00:00
Ben Clayton 7862da9901 Fix test/compute_builds.wgsl
The shader was failing new binary operator validation

Bug: tint:354
Change-Id: I779d96c19b12675ccd5dc348fa0d8be3aadf38c1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45121
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-17 18:43:53 +00:00
Ben Clayton e8bf942fef Add AUTHORS file
Fixed: tint:637
Change-Id: If46e9c37f16bf4fb84093ddf9437fa0a1e8b9ab0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44784
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-17 17:54:33 +00:00
James Price 4ffd3e2ea5 [spirv-writer] Handle non-struct entry point return values
Generate a global variable for the return value and replace return
statements with assignments to this variable.

Add a list of return statements to semantic::Function.

Bug: tint:509
Change-Id: I6bc08fcac7858b48f0eff62199d5011665284220
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44804
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-17 14:24:04 +00:00
Ben Clayton 417b82291b Fix GCC warning about an unused local variable
Change-Id: Idd064713ce8919e96f84a8a13fa04779fa889208
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44871
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-17 14:00:44 +00:00
Antonio Maiorano d600972e49 CMake: fix warnings on msvc builds
Remove /W3 from default flags, and disable a couple of warnings:

C4127: conditional expression is constant
C4458: declaration of 'identifier' hides class member

These match our warning settings of Clang/GCC more closely.
Also fix some valid warnings in some tests.

Change-Id: I46cb30b93ece74039db4aa0d6b52a675ee36859d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44960
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-17 13:32:54 +00:00
James Price 4f4534df3a Enable InsertBefore to work on global declarations
Use it for entry point IO sanitizing transforms to fix cases where structures were being inserted before type aliases that they reference.

Also fixes up some ordering issues with the FirstIndexOffset
transform.

Change-Id: I50d472ccb844b388f69914dcecbc0fcda1a579ed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45000
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-03-17 09:26:04 +00:00
Corentin Wallez 4f4a285750 Suppress -Wreturn-std-move-in-c++11 for building in Skia
Bug: dawn:706
Change-Id: I882b58cf19a678f1eaa55cacc19a1ada67b55cce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44868
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-17 09:13:04 +00:00
Corentin Wallez 9496f28775 BUILD.gn: Remove the temporary group with Dawn migrated.
Bug: dawn:706
Change-Id: I60aa97845cdfce263afc34947c597ceb5b8e6fb0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44861
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-03-17 07:41:03 +00:00
Ben Clayton 50f169dcc8 debug: Add TINT_UNIMPLEMENTED()
Use this when we have code TODOs, so we can easily find them.

Change-Id: I7720d4cc3a52d51f3c240e86611b4a8eea566a6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44863
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-03-17 04:55:33 +00:00
James Price 15dcd8fb15 [validator] Fix return statement type validation for aliases
Unwrap type aliases from the function return type before comparing to
the return value.

Add additional test coverage for aliased and non-aliased cases.

Change-Id: I4aa43f681468cd2c68e84da71222aea952117c1a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44923
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-16 22:08:13 +00:00
Ben Clayton 1222c15172 Fix CMake build warnings / errors
Fixed: tint:651
Change-Id: I6d4119f4acecbea1555a85c53b4f3e905be2c556
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44866
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-16 21:58:23 +00:00
Ryan Harrison 377acdda46 Add Storage Texture bindings to GetResourceBindings
BUG=tint:647

Change-Id: Iebf8e71366cf816d46b1acca11c1a0a7f1183530
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44900
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-16 20:52:33 +00:00
Antonio Maiorano fb5897057b Add CMakeSettings.json with convenient defaults
This is used by Visual Studio's CMake integration. I've added configs
for targeting x64 and x86, Debug and Release, as well as the Clang
(clang-cl) variants. Choosing a Clang variant will prompt the user to
install Visual Studio's clang-cl support via the installer.

Change-Id: I6cc33ea8a3c5dced8df476d72629fdec5044663b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44883
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-16 18:52:53 +00:00
Antonio Maiorano cb21680714 TestHelper: rename td_ to resolver_
Change-Id: I7fb82fa6c2802747762fca3af1d5e59eb44ffb5a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44881
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-16 16:31:33 +00:00
Antonio Maiorano ac39fb44bb CMake: bump warning level from 3 to 4 for msvc builds
This enables, among other things, warnings on unused variables, which
matches our default Clang and GCC builds.

Change-Id: I3f405b1a5c30e428542cd72d50f07910e477cea6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44880
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-16 15:05:33 +00:00
Ben Clayton 63c87d9582 Add .vscode/tasks.json
Contains a bunch of helper tasks for building the project and pushing changes to gerrit

Change-Id: I1f2b118e0fd811c5b67f26803d94569609697284
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44785
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-16 13:33:23 +00:00
Antonio Maiorano be0fc4e929 Validate binary operations
This change validates that the operand types and result type of every
binary operation is valid.

* Added two unit tests which test all valid and invalid param combos. I
also removed the old tests, many of which failed once I added this
validation, and the rest are obviated by the new tests.

* Fixed VertexPulling transform, as well as many tests, that were using
invalid operand types for binary operations.

Fixed: tint:354
Change-Id: Ia3f48384256993da61b341f17ba5583741011819
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44341
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-16 13:26:03 +00:00
Ben Clayton 1691401179 Another fix for run-parallel
Don't return error code 1 when some invocations return with no errors.

Change-Id: I4eec555bc188bcfaa3424dbb70a3391062ba87f6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44782
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-15 22:15:22 +00:00
Ben Clayton 7d80c2783a validator_decoration_test: Handle new size / align decorations
Bug: tint:626
Change-Id: Ibaaff85d4cd2e0a0bce05006d2bf74ca884a8db0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44783
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-03-15 21:59:42 +00:00
Ryan Harrison 935927d0f6 [inspector] Remove check that uniform buffers have an access wrapper
BUG=tint:641

Change-Id: I49c2e59e1555c839665cde9d30bb8181c4b28814
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44802
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-15 21:30:52 +00:00
David Neto 5a01b72b98 Remove unusued param
Fixes GCC build

Change-Id: I0d89d48bdaa24f4199afa03197e8bbf1a0576b28
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44803
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-15 21:28:22 +00:00
Arman Uguray 3549e2ea8c Resolver: Enforce vector constructor type rules
Added enforcement for vector constructor type rules according to the
table in https://gpuweb.github.io/gpuweb/wgsl.html#type-constructor-expr.

This surfaced a number of existing tests that violated some of these
rules or had a type-declaration related bug, so this CL fixes those as
well (these tests either passed the incorrect number of arguments to a
vector constructor or relied on implicit conversions between numeric
types).

Fixed: tint:632
Fixed: tint:476
Change-Id: I8279be3eeae50b64db486ee7a91a43bd94fdff62
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44480
Commit-Queue: Arman Uguray <armansito@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-15 21:21:33 +00:00
Ben Clayton 2f9ced0341 Update DEPRECATED comments about offset decorations
Let's keep these for the SPIR-V reader case. The way things currently work is actually nicer than attempting to generate size / align decorations in the SPIR-V reader.

Change-Id: I83087c153e3b3056e737dcfbfd73ae6a0986bd7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44684
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-15 20:34:22 +00:00
Ben Clayton 822fa54d87 writer/wgsl: Fix size / align decoration emission
This was broken by a rebase of the Default Struct Layout change.
This went unnoticed because there was no test coverage for these. Added.

Also replace `[[offset(n)]]` decorations with padding fields.

Bug: tint:626
Change-Id: Iad6f1a239bc8d8fcb15d18a204d3f5a78a372350
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44683
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-15 20:25:12 +00:00
Ben Clayton fd3cf82056 Fix missing printed errors from run-parallel
These errors were captured, but not printed.

Fix the lint error that was not being displayed.

Change-Id: I56da5c3a044b8a8e41695883ce780aca6245ad04
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44780
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-15 20:18:32 +00:00
David Neto c7e4032009 Rename Transform() to Run() to fix build
Two changes merged that were not compatible (44681 and 44603).

Change-Id: Ib35c4d738e4749b904c0c83626de730de63b8417
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44800
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-15 20:10:02 +00:00
Antonio Maiorano 5106a0653c Add CastableBase::To() overload with predicate
This allows for a more optimal way to filter the result of To(). Updated
Type query functions to make use of it. Added tests.

Change-Id: If3a65259345fbe6b92c6d367ab01fa718bb7cfee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44463
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-15 19:55:02 +00:00
Ben Clayton b903aadcd2 Fix GCC warnings / errors
Fixed: tint:636
Change-Id: Ic1bb602b07d659e553d8cb09fd5898482c40c0c1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44681
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-03-15 19:19:42 +00:00
James Price 6eda12a55d [wgsl-writer] Use EmitDecorations() for function parameters
Removes some duplicated code.

Change-Id: I05120e5f443810e54babb842f0f993e4e0a7da79
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44603
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-15 17:35:02 +00:00
Antonio Maiorano a089a56c73 Add Castsable::IsAnyOf<T1, T2, ...>()
This makes it a little easier to check if an object is one of any of the
types provided. Updated Type query functions to make use of IsAnyOf.
Added tests.

Change-Id: I12ea62b32042b6675d998ab85b86f2fe15861330
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44462
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-15 17:29:03 +00:00
Antonio Maiorano 81a4753c38 Castable: factor out Is and As to free standing functions
These can now also be called with nullptr and will return false or
nullptr respectively.

Change-Id: I5fcf292503dd718f8d3771c7c39c204ce03ff4f7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44461
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-15 17:20:51 +00:00
James Price cc193de025 [wgsl-writer] Generate decorations on function return types
Bug: tint:576
Change-Id: I60d046fb4db558daf52178600b962eaeb6d3f843
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44602
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-15 17:15:23 +00:00
James Price feecbe0d83 [wgsl-reader] Allow decorations on function return types
Add a return type decoration list field to ast::Function.

Bug: tint:513
Change-Id: I41c1087f21a87731eb48ec7642997da5ae7f2baa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44601
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-15 17:01:34 +00:00