Also test initializing a const from a function parameter.
Bug: tint:642
Change-Id: Ic10a4e8b5a2f67f56bc3720cb59f8d306e175d66
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45520
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This regression was accidentally introduced by my CL:
https://dawn-review.googlesource.com/c/tint/+/45382
I had removed too much of ValidatorImpl::ValidateFunction, including
its pushing of function parameters to the variable stack. As a result,,
any function parameters referenced by a function would fail the
Validator. This CL restores this bit, and adds a test for this case.
Bug: tint:642
Change-Id: I839057e73cabfb11631571ce806dec09f5d9f966
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45500
Auto-Submit: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This has now been added.
Bug: tint:652
Change-Id: I5ed8a825dcca500748d5ced66f1ce41dd0c9d6b8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45344
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
To try and speed up the presubmits a bit.
Also add some stage duration timings, so we can tell what takes all the
time.
Bug: tint:652
Change-Id: Ic0a25a9485dc58e6d45b5129756fe9e704380d02
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45341
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Formerly, the resolver would process arrays and structs first, then
global variables, and finally functions. As we move validation from
Validator to Resolver, we need to process these nodes in declaration
order instead so that we can validate use-before-declaration. This
matches how the Validator processed nodes.
Fixed all tests that failed after this change mainly because of
variables declared after usage.
Bug: tint:642
Change-Id: I01a9575dcfff545b0a056195ec5266283552da38
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45383
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Declare enum <-> string mapping once.
Don't use `default:` so the compiler moans when the enum is not catching cases.
Change-Id: I4c8903ef75c76b1881971b66ec3b49667dcc2218
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45340
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
* Fixed many tests that now failed validation. Most of the time,
functions declared that they returned a type, but with no return
statement.
* ProgramBuilder::WrapInFunction now returns the function is creates,
and std::moves its StatementList.
* ProgramBuilder: Added Return function to create ast::ReturnStatements
more easily.
Bug: tint:642
Change-Id: I3011314e66e264ebd7b89bf9271392391be6a0e5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45382
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
A couple more headers that should have been deleted in 95d4077.
Change-Id: Icd051842d0ff143ea74eb62c636506dc2a955681
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45380
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
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>
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>
* 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>