As all loops in the parser require `synchronized_` to be true, don't set this to true if we've hit the maximum number of error diagnostics.
This lets the parser bubble up as soon as the limit was reached, instead of only aborting once we finally reach the top level loop.
ClusterFuzz has uncovered a number of cases where, in a loop, it can produce an error, then resynchronize, then error again on the next loop iteration. This produces more than the max limit of errors, and can stall the tests long enough to time out.
No unit tests for this, as it requires a really contrived input to trigger, and to exhaustively catch all the places we now call maybe_set_synchronized() would result in a large colleciton of horrible tests. Instead, let ClusterFuzz do the testing.
Fixed: chromium:1224031
Fixed: chromium:1224032
Fixed: chromium:1224042
Fixed: chromium:1224049
Fixed: chromium:1224050
Fixed: chromium:1224130
Fixed: chromium:1224131
Fixed: chromium:1224132
Fixed: chromium:1224144
Fixed: chromium:1224191
Change-Id: I63f160e28d13b85ee92e1b921239d7fb8ac22a08
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56070
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
These are expressions, and not specific to `var`s.
Break the tests up into finer granularity.
Bug: tint:656
Change-Id: I6873407127871dfaec55d90f02e0490eef929a30
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56071
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Add `out` parameters to expression and type generators.
Use the new helper classes in TextGenerator.
Cleans up bad formatting.
Prepares the writer generating 'pre' statements, required for atomics.
If-else statements are generated slightly differently. This is done so that 'pre' statements for the else conditions are scoped correctly. This is identical to the HLSL writer.
Bug tint:892
Change-Id: I4c6e96c90673ba30898b3682bf3198497d63a2d4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56067
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
logical negation operand must be 'bool' or 'vecN<bool>'
complement operand must be be 'i32', 'u32', 'vecN<i32>' or 'vecN<u32>'
Negation operand must be 'i32', 'f32', 'vecN<i32>' or 'vecN<f32>'
Bug: tint:916 chromium:1216597
Change-Id: Ic88a124a32d16b542560da3ca1c159968d4043a0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55860
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Functions that are not entry points cannot have any attributes on
their return types.
Validate the builtin store types for return types.
Bug: tint:851
Change-Id: I718356b3ab06db4b4502a53b81790e4de0ecfeac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56100
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Add more docs to the cli.h file in SPIRV-Tools fuzzer.
Change-Id: I327c0f6919c07724ecb471655fb1a284fc6c43ae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56065
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Remove `pre` and `out` parameters from most generator methods.
Use the `out_` string stream in TextGenerator, add helpers to TextGenerator to simplify line printing.
Remove the `pre` and `out` fields from TestHelper.
Cleans up the `pre` aspects of the HLSL writer, so the same concept can be used by the MSL writer.
Fixes indentation bugs in formatting.
Change-Id: Ia35daf632c7c7b84a6fbf3b9ae42baaeb3c97649
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55960
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
When using Visual Studio (MSVC), have Doxygen output its warnings with
the file/line prefix in the MSVC standard, so that double-clicking on
the warnings brings you to the right source location.
Change-Id: If492f83a651cf6d4a38186c9e36ffcb57f1d72ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55801
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
There's a lot of missing doxygen in the cli.h file. Add a TODO and disable it for now.
Change-Id: Iebd2bf76be73ad0233e4a7dbd893fc3603efa172
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56061
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Vasyl Teliman <vasniktel@gmail.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Allows transforms to assert their dependencies have been run before they
are.
Also allows the backends to validate that their sanitizers have been run
before they're used.
Change-Id: I1e97afe06f9e7371283bade54bbb2e2c41f87a00
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55442
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
This change adds a new tint fuzzer that uses SPIRV-Tools to fuzz SPIR-V binaries.
The fuzzer works on a corpus of SPIR-V shaders. For each shader from the corpus it uses
one of `spirv-fuzz`, `spirv-reduce` or `spirv-opt` to mutate and then runs the shader through
the Tint compiler in two steps:
- Converts the mutated shader to WGSL.
- Converts WGSL to some target language specified in the CLI arguments.
The list of all supported CLI arguments and their description is in the cli.h file.
Change-Id: I95c0741b78ccc600dd9a73c371d520bdf7814352
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41945
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Vasyl Teliman <vasniktel@gmail.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Alastair Donaldson <allydonaldson@googlemail.com>
Entry point function parameter can only have builtin and location
attributes (unless a disable validation attribute is present). Other
functions cannot have any decorations on their parameters.
Fix parameter creation in the CanonicalizeEntryPointIO transform for a
case where it was not stripping attributes that are not valid for
function parameters.
Change-Id: I000908aa2dc007c52d100c5f65bca051a49bec9a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55863
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>
Use a DisableValidationDecoration to allow these storage classes only
for variables generated by the SPIR-V sanitizer. This is also used in
the Inspector tests, since the Inspector is currently run *after* the
SPIR-V sanitizer. These tests will be removed when this is no longer
the case.
Also validate that builtin/location decorations are not used on
variables (unless they have input/output storage class).
Fix or delete all of the other tests that were wrongly using these
storage classes and attributes.
Bug: tint:697
Change-Id: I8be7fb16191f5e2bed9f7dfb700e51f3b97fd1fe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55862
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Describes what Tint system raised the diagnostic.
Use this information in the fuzzers to distinguish between expected and unexpected failure cases in the Transform fuzzer tests.
Fixed: chromium:1206407
Fixed: chromium:1207154
Change-Id: I3b807acafe384a2fc363d2a4165a29693450b3cf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55254
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
HLSL usually implicitly casts a vector down to a scalar, but this breaks when passing the vector to RWByteAddressBuffer.Store (for DXC only).
Fixed: tint:827
Change-Id: I67d0bc6e9185de3d434a7aaeb575d83850111ec5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55760
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>
This test is invalid for multiple reasons (wrong types, wrong stages,
global variable instead of a parameter). The shader IO E2E tests give
better coverage for this anyway, so just delete the unit test.
Change-Id: I1627addf1e407e473e33043341d742958ceebca5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55861
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This is needed to roll Tint into Dawn, and makes sense for this to be
optional anyway.
Bug: tint:387
Change-Id: Ia3a42f8add36dfba954dd0a5e06f2f84d8e95464
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55684
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This fixes the SPIR-V and MSL tests for these intrinsics.
Change-Id: Id6f48682285ff17cb1fa7ef618f34b02f553332b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55681
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
The feature is not yet finished in WGSL.
Fixed: tint:804
Change-Id: I5268126f68316e57ee60d099f2000223703845df
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55500
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
The CanonicalizeEntryPointIO transform now takes an optional config
option for a fixed sample mask. If there was no sample mask in the
authored shader, add one and return the fixed mask, otherwise AND the
fixed mask with the authored value.
Add a config option to the MSL sanitizer to receive a fixed sample
mask and pass it through to CanonicalizeEntryPointIO.
Bug: tint:387
Change-Id: I1678d915b19a718005d5832c5d624809ee432587
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55520
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This reverts commit 6330260f7d.
Reason for revert: Need by this CL which was also reverted:
https://dawn-review.googlesource.com/c/tint/+/55402
Original change's description:
> Validate that in/out storage classes are not used
>
> Use a DisableValidationDecoration to allow these storage classes only
> for variables generated by the SPIR-V sanitizer.
>
> Fix or delete all of the tests that were wrongly using these storage
> classes.
>
> Bug: tint:697
> Change-Id: Ife1154f687b18529cfcc7a0ed93407fd25c9868e
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55404
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Auto-Submit: James Price <jrprice@google.com>
> Commit-Queue: James Price <jrprice@google.com>
TBR=bclayton@google.com,jrprice@google.com,noreply+kokoro@google.com,tint-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: I54db99d6d0fdf28c27a1f2b9858b84f5cd197409
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: tint:697
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55660
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
This reverts commit 055901b3cd.
Reason for revert: Is causing a *lot* of test failures in the tint -> dawn roll
Original change's description:
> inspector: Remove legacy shader IO support
>
> Bug: tint:697
> Change-Id: Ifa01fa459daa5c2f4b47833cd14ea1b303455c34
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55402
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: James Price <jrprice@google.com>
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Auto-Submit: James Price <jrprice@google.com>
TBR=rharrison@chromium.org,bclayton@google.com,jrprice@google.com,noreply+kokoro@google.com,tint-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: I692a09eeda8e9e7271f032aa6d4cf0630d54c26a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: tint:697
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55580
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
VectorInsertDynamic normaly inserts a temporary variable.
But if the source vector is already a hoisted variable, then
reuse that instead. This avoids defining the same name twice.
Bug: tint:804
Change-Id: I69c20c11d462c148261bb0646db698dc7850495d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55362
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Use a DisableValidationDecoration to allow these storage classes only
for variables generated by the SPIR-V sanitizer.
Fix or delete all of the tests that were wrongly using these storage
classes.
Bug: tint:697
Change-Id: Ife1154f687b18529cfcc7a0ed93407fd25c9868e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55404
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Composite insert normally inserts a temporary variable.
But if the composite value is already a hoisted variable,
then reuse that instead. This avoids defining the same name twice.
Also add AddressOfIfNeeded and use it when processing the operand
of an OpCopyObject or when making a let-declaration. Only take the
address in these cases when the corresponding SPIR-V type is a
pointer.
Bug: tint:804
Change-Id: I44f4289a557db919d8f1805e187a9b2a95c1efe0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55361
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Also remove the unreachanble constructor logic in EmitHandleVariable.
Variables of the handle storage class cannot have initializers.
Fixed: tint:173
Change-Id: I7c997a8b6a70308ff9b5c42fa1198810ee365bac
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55258
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
We shouldn't be calculating array strides with the packed element size.
Bug: tint:180
Bug: tint:649
Bug: tint:898
Change-Id: Ifa23517480435610b20c1597c2fc2c2837f4280a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55257
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Remove special case handling of pointers and values related
to builtins SampleId, VertexIndex, and InstanceIndex.
These map to private variables with store type matching the
type stated in the SPIR-V code. There is no need to generate
special case code for user-written functions accessing those variables.
Therefore:
- Remove SkipReason enums associated with those builtin inputs
- Remove newly unreachable code.
Bug: tint:508
Change-Id: I22ea86d49e14f171a92863d9f02145606ad37683
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55321
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
Varaibles can infer types now, in which case the type_ field is null.
Fixed: chromium:1221120
Change-Id: I0cb2a6a2e8128c56625f48940cf73cf4cadb22ce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55252
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>