Commit Graph

2508 Commits

Author SHA1 Message Date
Sarah cb0309ed6c validation: fix error msg for assign to 'let' and 'function parameter'
Bug: tint:903
Change-Id: Ie2220d533f2227be717f61fa702514e2aeb052c8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56300
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-06-28 20:44:31 +00:00
James Price e37044a6cc ast: Add InterpolateDecoration and related enums
Bug: tint:746
Change-Id: Ifd0de8b0e4400a153e67a8e301a7d0523e75898a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56240
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>
2021-06-28 18:20:23 +00:00
Ben Clayton c41c7cdf31 reader/wgsl: Only resync if num errors less than limit
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>
2021-06-28 16:09:57 +00:00
Ben Clayton 65cb20c1db test: Move 'splat' tests to expressions, split up
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>
2021-06-28 15:56:57 +00:00
Ben Clayton f24b37e122 writer/msl: Rework string printing
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>
2021-06-28 15:30:57 +00:00
Sarah a5715e3320 validation: unary operands
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>
2021-06-28 14:09:33 +00:00
Sarah ac5dbd2d0f validation: add an internal decoration to allow atomic function parameters
Bug: tint: 927
Change-Id: Ia6f31bdbfa51c92b742faa89089649865bb45ad5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56020
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-06-28 14:05:25 +00:00
Corentin Wallez 3cbbeaf1db sample: add a --fxc option to validate HLSL with FXC
Change-Id: I39d684a71d9f985a1f30b871f08f51bdf50f17a1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56064
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
2021-06-28 12:02:17 +00:00
James Price 1b1d963d7b Validate attributes on function return types
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>
2021-06-28 09:53:37 +00:00
Vasyl Teliman 67993b955e Improve docs in the spirv_tools_fuzzer
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>
2021-06-28 09:47:57 +00:00
Ben Clayton c03a09c106 writer/hlsl: Rework string printing
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>
2021-06-26 11:11:55 +00:00
Antonio Maiorano e25a8fc7f0 Doxygen: set warning format for MSVC builds
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>
2021-06-25 14:53:06 +00:00
Antonio Maiorano 6241f962a1 Kokoro-Linux: fail on Doxygen warnings
Change-Id: Ib85e835ea70fd84a3cb4be03e7ff5afdd7782a82
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55641
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-06-25 14:00:36 +00:00
Ben Clayton e225b556c6 fuzzers: Silence doxygen warnings
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>
2021-06-25 12:28:56 +00:00
Ben Clayton b5cd10c7bd Program: Track what transforms have been applied
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>
2021-06-25 10:26:26 +00:00
Ben Clayton 5b9203cc05 test: Emit expected HLSL file
Sarah fixed the test with https://dawn-review.googlesource.com/c/tint/+/55122

Bug: tint:506
Change-Id: Ia42f6f3fc383214d653353d8de93ab154fd50bc8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55884
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-06-24 22:37:48 +00:00
Ben Clayton 07b59ca230 writer/spirv: Generate load of atomic value arguments
Fixed: tint:926
Change-Id: Ia27abe605ebfb46a7524b50500ecebd6e4656d1d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55883
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-06-24 19:01:06 +00:00
Ben Clayton 9d3e2acd35 Remove accidential commit
Change-Id: I54ab31576f6027ad858bf99e871cbdb45f832042
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55881
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-06-24 18:39:46 +00:00
Vasyl Teliman 0b3611b8c8 Add spirv-tools fuzzer
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>
2021-06-24 18:10:46 +00:00
James Price c3f19081f8 Validate attributes on function parameters
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>
2021-06-24 16:20:16 +00:00
James Price 14c0b8acbf 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. 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>
2021-06-24 15:53:26 +00:00
Ben Clayton ffd28e2e1a diag: Add System enumerator to all diagnostics
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>
2021-06-24 11:27:36 +00:00
Antonio Maiorano 261643bb9f Fix doxygen warnings
Change-Id: I5b3765ca0362e517990334d47f9defa673732a04
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55800
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-24 09:15:06 +00:00
Sarah 9548531887 validation: workgroup memory cannot be used in vertex/fragment stage
Bug: tint:907
Change-Id: I62c528437fabcd1a1f42c46ab6279ef9a14d96d2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55640
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-24 08:56:16 +00:00
Ben Clayton c8434889d8 writer/hlsl: Swizzle depth texture intrinsics
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>
2021-06-24 08:46:06 +00:00
James Price 9cae45e6ca writer/wgsl: Remove builtin unit test
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>
2021-06-24 08:20:46 +00:00
Sarah 57a737ba3b validation: validate store type of builtin variables
Bug: tint:506
Change-Id: I780e9bfaa1963b351312916630ef017c3e89db02
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55122
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-06-23 17:35:42 +00:00
James Price ae0bf04ad2 msl: Default the sample mask config parameter
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>
2021-06-22 22:57:09 +00:00
James Price e0cc771e0a intrinsics: Limit fwidth builtins to fragment shaders
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>
2021-06-22 20:19:49 +00:00
David Neto f37f8df38b spirv-reader: explicitly error out on extended arithmetic
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>
2021-06-22 20:17:09 +00:00
James Price c32e8f641b msl: Generate a fixed sample mask if requested
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>
2021-06-22 20:08:29 +00:00
David Neto f9699b2248 spirv-reader: further cleanup of legacy IO
Bug: tint:508
Change-Id: I0c72cd06db70fa5275fff3bca2ed31febb9f49a9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55521
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-06-22 19:42:49 +00:00
James Price c0c7915190 Revert "Validate that in/out storage classes are not used"
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>
2021-06-22 17:13:51 +00:00
David Neto 35b514ff06 spirv-reader: test conditional address-of on function call
Bug: tint:804
Change-Id: I7178270fcd8487a20a4e25a2e5389a07e22b4dd6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55363
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-06-22 15:48:31 +00:00
Ben Clayton 3c9086d6a5 Revert "inspector: Remove legacy shader IO support"
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>
2021-06-22 11:23:00 +00:00
David Neto 7aac7b521e spirv-reader: Handle vector insert dynamic into a hoisted variable
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>
2021-06-21 21:45:36 +00:00
Antonio Maiorano f19e0e4360 Validate that functions return atomic-free plain types
Bug: tint:876
Change-Id: If00aa2c64fc3039d6271d3c5e35c05635a6bf3d1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55480
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-06-21 20:51:16 +00:00
Ben Clayton fd75bd0965 test: Add test cases for zero value constructors
Fixed: tint:477
Change-Id: I087c24904ab2f38524ab2c39092fbfb277fdba3b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55256
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-21 20:31:36 +00:00
James Price 6330260f7d 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>
2021-06-21 20:27:56 +00:00
David Neto 53a0d2681a spirv-reader: Handle composite insert into a hoisted variable
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>
2021-06-21 20:19:46 +00:00
Ben Clayton 41f21fe05b writer/hlsl: Emit zero values for private variables
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>
2021-06-21 19:37:58 +00:00
James Price 3b02d54ab0 vertex_pulling: Remove legacy shader IO support
Bug: tint:697
Change-Id: Ia4665eb1a520218e05a5878ea5abb3604aff4a6f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55403
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
2021-06-21 19:37:26 +00:00
Ben Clayton e7257eb2fb reader/wgsl: Prevent stack overflow in unary_expression()
Fixed: chromium:1209237
Change-Id: I14b4777aaee3ee7a34baf8a218db28f54b81af84
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55253
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-21 19:36:26 +00:00
James Price 055901b3cd 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>
2021-06-21 19:34:46 +00:00
Ben Clayton 8d133e2ca5 writer/msl: Fix array stride calculations
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>
2021-06-21 19:27:56 +00:00
Ben Clayton a05669ae71 Add test case for dawn:947
Bug: dawn:947
Change-Id: Ie594f084d7642e470d058a0fd2b5f43e2e9f72cc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55441
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-21 19:27:26 +00:00
David Neto 3d5453ce9c spirv-reader: remove builtin-inputs special cases
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>
2021-06-21 19:21:36 +00:00
Ben Clayton 4d94eee072 ast: Fix nullptr deref in Variable::info_to_str
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>
2021-06-21 19:20:16 +00:00
Ben Clayton def7313523 test: Add loop test cases
Bug: tint:833
Bug: tint:914
Change-Id: Ieb34c734ad08c632c8d4e6152d856ec28f35cf85
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55249
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-21 19:04:56 +00:00
Sarah c3f8fdfe69 validation: no statically dead statement
Bug: tint:65
Change-Id: Iefc103afe77bc4423ec981eeb3bf066d239e99de
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54981
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-06-21 17:53:56 +00:00