This also creates a new commit to test 20% of realms :)
R=rharrison
Bug: chromium:1216166
Change-Id: I5f0f9b9b4865bd9d30592a387499b2f909b3fa72
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57466
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
ConstantValueOf() obtains the constant value from the logic in resolver_constants.cc. This is better tested, and is the foundation of Tint's constant folder.
Change-Id: I42036f3ff4ab684b4864cd69856de1715b38d246
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57702
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Use the new semantic constant value information to significantly reduce the complex indexing logic emitted for UBO accesses.
This will dramatically reduce the number of `for` loops that are decayed to `while` loops.
Change-Id: I1b0adb5edde2b4ed39c6beafc2e28106b86e0edd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57701
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Move the bulk of the constant evaulation logic out of transform::FoldConstants and into Resolver and sem::Expression.
transform::FoldConstants now replace TypeConstructor nodes that have a constant value on the expression.
This is ground work to:
* Cleaning up the HLSL uniform buffer indexing, which is `/` and `%` arithmatic heavy
* Prepares us to handle `constexpr` when it lands in the spec
* Provide a centralized place to do constant evaluation, instead of the
having similar logic scattered around the codebase.
Change-Id: I3e2f542be692046a8d243b62a82556db519953e7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57426
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
This change implements a new fuzzer. It mutates a WGSL shader by traversing
the AST of a program and applying various transformations that might or might not
be semantics preserving.
Change-Id: I6b144bd1067444c3f0b815ba1a646aaf6e739b52
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52160
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Vasyl Teliman <vasniktel@gmail.com>
Reviewed-by: Alastair Donaldson <allydonaldson@googlemail.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Remove sanitizer transform fuzzers, as these will no longer be
publicly visible. We should fuzz the generator options instead.
Change-Id: If8f2c70f505bdaecd62a2f53a6586c3b84bd1c33
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57760
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This reverts commit fd5829e5ea.
Reason for revert: Temporarily reverting as this is preventing a tint->dawn roll, which is needed to fix the dawn->chrome roll.
Original change's description:
> Validate storage class constraints
>
> As defined by https://gpuweb.github.io/gpuweb/wgsl/#storage-class-layout-constraints
>
> Bug: tint:643
> Change-Id: I9c78ba69a792a80c263a17b0a6e9b4810fdb7f30
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56780
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>
TBR=bclayton@google.com,amaiorano@google.com,noreply+kokoro@google.com,tint-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: I8dbd0e46b3e3291ef08797a196d0d9abd2a78845
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: tint:643
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57704
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
R=rharrison
Bug: chromium:1216166
Change-Id: I4103a26046163a1d71ac9a1e039dfe4c06ceb100
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57425
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Kokoro: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Andrii Shyshkalov <tandrii@google.com>
... once the maximum number of errors have been reached.
https://dawn-review.googlesource.com/c/tint/+/56070 introduced maybe_set_synchronized(), which only set synchronized_ when the number of errors reported was less than max_errors_, but it seems the fuzzers have found ways to generate an excessive number of errors that keep the parser synchronized.
Revert 56070, and instead check the synchronized state along with the error count for every unbounded loop in the parser.
Fixed: chromium:1226655
Fixed: chromium:1226379
Change-Id: I178d758ac1424d4d19923fe6a3d9e123879b9eae
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57427
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>
Report whether one was generated so that Dawn knows to use the
`-fpreserve-invariance` compiler option.
Bug: tint:772
Change-Id: Ife1eb05265646727dc864f12f983781af4df3777
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57644
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Also:
* remove redundant luci-scheduler permission.
* make ./main.star executable on mac/linux.
R=rharrison
Bug: chromium:1216166
Change-Id: Iae6d915d5327218c4c1f80db273be347cf855765
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57424
Auto-Submit: Andrii Shyshkalov <tandrii@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Make sure the other backends ICE on unrecognized attributes.
Add E2E tests, currently skipped for the other backends.
Bug: tint:772
Change-Id: I4e68d111ff79b19ebb6c574058a91debcb746011
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57642
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This is only valid on structure members and entry point return
types. Additionally, this can only be applied to a position builtin.
Bug: tint:772
Change-Id: Iffd774ca768ab66373678ecf0eb57c766767e92b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57641
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This reverts commit d09317c0b5.
Reason for revert: Breaks chromium build. See: crbug.com/tint/970
Bug: tint:970
Original change's description:
> Generate shader corpora for fuzzers
>
> Adds scripts that generated corpora of WGSL and SPIR-V shaders for
> the tint fuzzers, from test cases in the repository.
>
> Fixed: tint:966
> Change-Id: I7e86ef5e34676d0c4f5b7e413a5c0f444fca08ff
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57204
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
> Commit-Queue: Alastair Donaldson <afdx@google.com>
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I5bdcfe33c3e4d1bc71b9e51c650c0e7318c561e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57428
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This CL removes the old token `Is<Name>()` methods which are no longer
being used in the parser or lexer. (Some of them were used in tests but
the generic `Is(<type>)` is used instead.
New `peek` methods are added which will peek if the given token comes
either next or at the given index.
Change-Id: I8d15f2a42889f981d273b6459d20c4202db1ae32
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57540
Auto-Submit: dan sinclair <dan.sinclair@gmail.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
By generating a helper function for these, we can keep the atomic expression pre-statement-free. This can help prevent for-loops from being transformed into while loops.
Change-Id: Id034ea5ea9be601661ddb78db973015d845c420f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57463
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
By generating a helper function for these, we can keep the atomic expression pre-statement-free. This can help prevent for-loops from being transformed into while loops, which can upset FXC.
We can't do the same for workgroup storage atomics, as the InterlockedXXX() methods have the workgroup-storage expression as the first argument, and I'm not aware of any way to make a user-declared parameter be `groupshared`.
Change-Id: I8669127a58dc9cae95ce316523029064b5c9b5fa
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57462
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
BUG=tint:963
Change-Id: I3cac636c194a36581f372ee22acad36d5e94eb07
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57500
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Kokoro: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
And remove the u32 overload of frexp (it's not in the spec).
Brings the number of failing tint end to end tests for MSL down to 19/1098.
The WG still haven't found consensus on reworking these two intrinsics.
It's very likely that their signature will change so that they return a structure instead of returning a value and outputing another as a pointer.
Until the WG makes a decision, let's implement these according to the current spec.
Some overloads are still failing due to MSL missing overloads of the pointer parameter being in the `threadgroup` address space.
I'm holding off fixing these until we know what's happening with these intrinsics.
See also:
https://github.com/gpuweb/gpuweb/issues/1480https://github.com/gpuweb/gpuweb/issues/1846
Change-Id: Ib6764e6659d840db41bc65fed2b8b283d1056c3d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57421
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
The level parameter needs to be zero for a number of texture overloads.
Bodging the template to emit 0 instead of 1 for any `level : i32` parameter is the easiest fix here.
Change-Id: I69222578efcd0d4f4f267fb59fec691b52786d9c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57301
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Removes the unneeded texture_external overload of textureSample from
intrinsics.def.
Bug: tint:858
Change-Id: I49935bae47542af7b440c74c96418e005daf9e19
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53940
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
A tool for compiling shaders on a remote machine.
Helpful for combining with `test-all`, so that a single non-windows
machine can validate SPIR-V, MSL and HLSL.
Change-Id: I3a0f70e6e4edd13952eb5dc72fbbed7c495036ee
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56940
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>
Adds scripts that generated corpora of WGSL and SPIR-V shaders for
the tint fuzzers, from test cases in the repository.
Fixed: tint:966
Change-Id: I7e86ef5e34676d0c4f5b7e413a5c0f444fca08ff
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57204
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Alastair Donaldson <afdx@google.com>
This reverts commit 26b6edc545.
Reason for revert: Seems to be breaking Dawn's tests. Investigation required.
Original change's description:
> writer/hlsl: Special case negative zero
>
> Fixed: tint:960
> Change-Id: I060bc6b7a9ad4d21dd5cadb4b68998c7e54ebaed
> Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57142
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Commit-Queue: Ben Clayton <bclayton@google.com>
> Auto-Submit: Ben Clayton <bclayton@google.com>
> Reviewed-by: James Price <jrprice@google.com>
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: Ia0b0ec996f2ed6b1599a344c970f155c12314ea9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57460
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Adds a new single-function API for the generators, which applies the
sanitizing transform and performs the generation in one step, and
returns a result object which contains the generated code and success
status/diagnostics.
The new APIs take an `Option` structure to control backend-specific
generation details (e.g. MSL fixed sample mask). The result objects
also provide backend-specific feedback (e.g. whether a UBO of buffer
lengths was generated).
HLSL needs a list of entry points to validate, and it's the HLSL
sanitizer that generates an entry point for programs that do not have
one. This change makes the HLSL generator return the list of
post-sanitize entry points so that the Tint executable can forward
them to the validation code.
Change-Id: I2d5aa27fda95d7c50c5bef41e206aee38f2fd2eb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57101
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Change-Id: Iecbdd554ad60160df04be4bf3581387cb5639e6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57420
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
These were removed from the spec in:
https://github.com/gpuweb/gpuweb/pull/1914
Bug: tint:921
Change-Id: I4e584fdee9cf540a192f12d1208595056e081410
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57300
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: James Price <jrprice@google.com>
Transforms a for-loop into a loop.
Will be required by the SPIR-V writer.
Bug: tint:952
Change-Id: Iba859bd144d702cee85374f2cfcb94cd7465ca98
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57202
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Runs the statement(s) at the end of the lexical scope
Change-Id: I74de02b7204b56016c7bbe71fee4ece498d3570d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51923
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
The language in the spec and details of the restriction have changed,
https://github.com/gpuweb/gpuweb/pull/1876.
BUG=tint:928
Change-Id: Ib9f4d5e785bb5e04d63e880fe8984a8683d759f0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57260
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Add Insert() methods to TextBuffer.
Allows generators to insert helper functions at the top of the output without requiring a scan of the program before generation.
Change-Id: I05f67ad05d189f2249e35cfac99536afccb5578d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57140
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
If provided, this option truncates long filenames to avoid unpleasant
line wrapping behavior for those of us that use narrow terminals.
Change-Id: I684b91b7aa4b0ae86a4cf9ed9f047b685ab97550
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57100
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>
WGSL:
* Remove vertex_idx and instance_idx.
These are now vertex_index and instance_index.
It seems this was removed once before, then reverted due to CTS
failures, but the original change never landed again.
* Remove the [[set(n)]] decoration. This has been [[group(n)]] for
months now.
API:
* Remove deprecated enums from transform::VertexFormat.
* Remove transform::Renamer constructor that takes a Config. This should
be passed by DataMap.
* Remove ast::AccessControl alias to ast::Access.
Change-Id: I988c96c4269b02a5d77163409f261fd5923188e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56541
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Also add missing msl macros to the renamer.
Bug: tint:951
Change-Id: I543e6eae885c979596ca63f9d6c7378dd5425e8a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56941
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
And add `vec` and `mat` to the reserved keyword list (see https://github.com/gpuweb/gpuweb/pull/1896)
Move these reserved keyword checks out of the lexer and into the parser.
Generate a sensible error message.
Add tests.
Change-Id: I1876448201a2fd773f38f337b4e49bc61a7642f7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56545
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
If the array size is greater than a threshold.
This is a work around for FXC stalling when initializing large arrays
with a single zero-init assignment.
Bug: tint:936
Fixed: tint:943
Fixed: tint:942
Change-Id: Ie93c8f373874b8d6d020d041fa48b38fb1352f71
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56775
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>