Commit Graph

619 Commits

Author SHA1 Message Date
Brandon Jones 41cbf0279c Reland ExternalTexture Gamma/Gamut Correction
Adds configurable gamma and gamut correction in Tint's external texture
transform. Adds constants in Dawn to perform correct conversion from
BT.709 to sRGB.

Bug: dawn:1082
Change-Id: I68b7ad7ccec29977c637a0a0d4f526cd47fe73d4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88367
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
2022-04-29 21:00:14 +00:00
Antonio Maiorano b909d5554d tint: Update SKIP lines with specific FXC bug
Error is:
internal error: compilation aborted unexpectedly

Bug: tint:1521
Change-Id: I482699d43001a95673bf44d97f5be314a3e69be2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88401
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-04-29 15:31:22 +00:00
Antonio Maiorano bdd2bc9750 tint: Update SKIP line for specific DXC failure
For error "access violation. Attempted to read from address
0x0000000000000048", added link to GitHub issue I opened. Helps to
understand what these errors are when reading the expectation files.

Bug: tint:1521
Change-Id: Ie2a1693f021e17586a4fe3b4dfe652bbdc877c49
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88363
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-04-29 15:31:22 +00:00
Antonio Maiorano 98685f34a5 tint: delete e2e tests that fail because Tint detects infinite loops
Bug: tint:1521
Change-Id: I9ae9af0b3799e3be1c2cb083e9f2ae5752b63b58
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88362
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-04-29 15:31:22 +00:00
Antonio Maiorano b52c8a4758 tint: delete e2e test for bug/tint/807
This test really only tests a Tint defensive check while we wait for a
proper spirv-val fix:
https://github.com/KhronosGroup/SPIRV-Tools/issues/4354

Bug: tint:1521
Change-Id: I02ae231657452dd7f92374df47e3e5a3976371e8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88361
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-04-29 15:31:22 +00:00
James Price 26ebe5ec36 tint: Refactor if-else statement representation
Instead of using an `if` node that has a list of `else` statements,
make each `if` statement have a single optional `else` statement,
which may itself be an `if` statement (or just a block statement).

This better matches the WGSL grammar (now that we have removed
`elseif`), and simplifies various pieces of code that handle these
statements.

Change-Id: Ie4272f1422224490ac598a03aa8b4dd00ba03010
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87940
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-04-29 00:14:53 +00:00
Ben Clayton 01004b7732 tint: Remove '_type' suffix from file names
These suffixes existed because the GN build errored when there were two files sets with the same name (ast + sem).
This is no longer required as the GN build splits these into two separate targets.

Change-Id: Ib451da33a5f4aa5c867cb99419dd252766dc3daa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88308
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-04-28 18:49:04 +00:00
Ben Clayton 617570a7da tint/writer: Replace scope_stack_, fix type ctor scoping.
ScopeStack is not needed here - the resolver already provides variable scoping with the sem::Variables.

Re-purpose scope_stack_ for a stack of Scope, which now holds the type constructor -> SPIR-V ID map.
This map needs to be per-scope, to fix issues like crbug.com/tint/1520

Fixed: tint:1520
Change-Id: Ifa7749338abf63652a1369e76cf5400be1c37298
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88301
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-04-28 16:23:03 +00:00
Antonio Maiorano 0da5e8b35d tint: regen skips for hlsl files that were missing error message in the output
Also mark all the skips for time out the same way for easier grepping.

Change-Id: Ie071df30431bded7838205c3a18483a5233687c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88341
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-04-28 15:11:03 +00:00
Ben Clayton 046abc08e8 tint/writer: Replace use of strings for cache keys
Concatenating strings to use for cache keys is horribly inefficent and very error prone.

Add a UnorderedKeyWrapper helper to allow types to be used as a unordered_map and unordered_set key. Use this for the type_constructor_to_id_ map.

Produces SPIR-V with some duplicate SPIR-V instructions for constructors removed.

Change-Id: Ib072d485ca28bb07f03e979c133cdce1f69ee482
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88300
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
2022-04-28 13:08:22 +00:00
Zhaoming Jiang 7098d3d692 tint: Add enable directive for extensions
In this CL the enable directive is implemented.
1. Add AST node for enable directive, assign a ExtensionKind (enum) for
each supported extension.
2. Use an unorder_set in ast::Module to record all required extensions'
kind.
3. Provide inspector methods for getting names of used extension, and
getting all used enable directives' extension names and location.
4. For different writer, the extension nodes are handled in different
ways. MSL and HLSL writers will just ignore the extension nodes, while
SPIRV and GLSL writers will emit corresponding code.
5. Implement unittests and end2end test for enable directive and
inspector, using a reserved extension name `InternalExtensionForTesting`.

Bug: tint:1472
Change-Id: I40cb4061554deb477bc2005d7e38c9718385f825
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86623
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
2022-04-27 02:27:52 +00:00
dan sinclair d3a5080c7b Fixup validator tests added during split from resolver.
This PR adds the validator_is_storable test into the CMakeList file
correctly and removes the helper files. The resolver helper is used
instead and a test helper to return the validator added into the
resolver.

Change-Id: I5b18bcc6373e3b39807af05cf5c058fab61ed4ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88041
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
2022-04-26 22:19:22 +00:00
Ben Clayton 1d882f55b7 Revert "Add External Texture Gamma/Gamut Correction"
This reverts commit 857175e59b.

Reason for revert: Suspected change for Dawn -> Chromium roll failures:

* https://chromium-review.googlesource.com/c/chromium/src/+/3607875/
* https://ci.chromium.org/ui/p/chromium/builders/try/mac-rel/982037/overview
* https://chrome-public-gold.skia.org/search?issue=3607875&crs=gerrit&patchsets=3&corpus=chrome-gpu


Original change's description:
> Add External Texture Gamma/Gamut Correction
>
> Adds configurable gamma and gamut correction in Tint's external texture
> transform. Adds constants in Dawn to perform correct conversion from
> BT.709 to sRGB.
>
> Bug: dawn:1082
> Change-Id: Id5eecc37f0224541bf36e2f9757e7e2047e4b66b
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87666
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>

TBR=cwallez@chromium.org,enga@chromium.org,brandon1.jones@intel.com,bclayton@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: Id3880e506172a18ff1258462c8c4cedb5c51c235
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:1082
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88001
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-04-26 12:20:02 +00:00
Brandon Jones 857175e59b Add External Texture Gamma/Gamut Correction
Adds configurable gamma and gamut correction in Tint's external texture
transform. Adds constants in Dawn to perform correct conversion from
BT.709 to sRGB.

Bug: dawn:1082
Change-Id: Id5eecc37f0224541bf36e2f9757e7e2047e4b66b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87666
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
2022-04-25 22:22:51 +00:00
Stephen White 790e4c2d60 GLSL writer: emit gl_PointSize = 1 in all vertex shaders for OpenGL.
The OpenGL ES 3.1 spec says:

"The point size is taken from the shader built-in gl_PointSize written by the vertex shader, and clamped to the implementation-dependent point size range. If the value written to gl_PointSize is less than or equal to zero, or if no value is written, the point size is undefined."

ANGLE/D3D11 will emit a warning on this and abort processing, causing dawn_end2end tests to fail.

Bug: dawn:1390
Change-Id: I6a56467842ba80d8a070af7240ee07bb111089dd
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87720
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-04-22 21:25:02 +00:00
James Price 98eb169692 tint: Track originating variables in the resolver
Attach the source variable to the sem::Expression nodes.

Bug: tint:1341
Change-Id: I71d8fcf5920c4daab9035c7a5615b34378889dac
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87606
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-04-22 17:40:33 +00:00
Brandon Jones 6cb57a9847 Change External Texture YUV-to-RGB Conversion to Use Matrix
Changes Dawn and Tint to use a 3x3 matrix for external texture
YUV-to-RGB conversions. This will allow us to use standard matrices
as they exist in SkYuvMath.

Bugs: dawn::1082
Change-Id: I8e0c7c3dc1c085d8f336da956aea9496913b70fa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86847
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
2022-04-21 16:02:36 +00:00
dan sinclair b3483b68f7 Fix test expectation missing blank line.
This broke when the inclusive language change was committed and the
newline was accidentally removed.

Change-Id: I447f34e07fd5f264b56e8ca205df558bd70946b6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87308
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-04-20 12:28:46 +00:00
dan sinclair fb5a492787 Fix inclusive language presubmit
The current presubmit has the filter inverted so it would only attempt
to match the filtered files. The file name also has to be converted to
`LocalPath` otherwise it's attempting to compare a python object to a
string and always fails to match.

Bug: dawn:1339
Change-Id: Ie7712dee60f6b9df2cb78c9feab11769f7ea1f02
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87080
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
2022-04-19 22:25:45 +00:00
James Price 0384932f1a tint: Replace smoothStep with smoothstep in tests
There were some tests that were still using the deprecated name, as
was the SPIR-V reader.

Bug: tint:1483
Change-Id: Ie919596712e05340110fbd872470a1b4c9a625c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86745
Auto-Submit: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-04-14 19:49:10 +00:00
Antonio Maiorano f625a6d57e tint: Make GLSL backend consistent with the others
Remove transform::Glsl and replace with a Sanitize function. Cleans up
the code, reduces allocations and copies, and makes it consistent with
the other backends.

Also add a copy of src/tint/.clang-format to include/tint/ to keep files
in there formatted as per the tint standard.

Bug: tint:1495
Change-Id: I8a44ffecc6b3d244517bceb374ed93063e96f218
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86205
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro-Run: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-04-11 21:13:10 +00:00
Ben Clayton 4d36557bce Normalize all line endings to LF
And force shader code to always use LF endings.

Post merge, there were a number of files that crept in with CRLF endings.

Some Tint end-to-end tests take objection to CRLF endings.

CRLF endings can be detected with:

```
git grep -I --files-with-matches --perl-regexp '\r' HEAD
```

And fixed with:

```
find . -type f -exec dos2unix {} \;
```

Bug: dawn:1339
Change-Id: Iee054bafd15875de744b86e28393cd8229bd3cfa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86140
Kokoro-Run: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-04-08 14:18:28 +00:00
Jiawei Shao 9d27aaaaa1 Always use 0 for the Depth operand of OpTypeImage
This CL is based on the below one with changes on the unittests:
https://dawn-review.googlesource.com/c/tint/+/60860

Bug: dawn:1030
Test: tint_unittests

Change-Id: I4624a0abd3c4905137b6ce1b3f57e4d9a4510eb4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85324
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86065
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-04-08 08:33:28 +00:00
Ben Clayton 9f49ac5493 tools: Replace copy-pasta scripts
There were a bunch of helper scripts to build a go tool and run it.
Replace these with a single 'run' command that takes the tool name and arguments.

Helps reduce maintainance, file spew.

Also add the 'tools/bin' directory to .gitignore. These are the cached tool binaries.

Bug: dawn:1339
Change-Id: I012c966736b4d93949f6142c342cdcfefa9f0083
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86063
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2022-04-07 18:26:45 +00:00
Corentin Wallez ebfbaf8f22 Add top-level OWNERS and scope Tint owners more tightly.
This is both a security/ACL best practice, but also to make the Gerrit UI
better suggest owners for CLs.

Bug: dawn:1339

Change-Id: Ia79b88d919707147d2726a7e4f3ff9080cd275b0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86067
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-04-07 17:59:14 +00:00
James Price d68d3a9809 Add support for increment/decrement statements
Refactor the ExpandCompoundAssignment transform to handle these
statements, which delivers support for all of the non-WGSL backends.

Fixed: tint:1488
Change-Id: I96cdc31851c61f6d92d296447d0b0637907d5fe5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86004
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-04-07 13:42:45 +00:00
James Price b02fe31e46 wgsl: Add support for increment/decrement statements
Implemented in both the reader and writer with E2E tests. Other
backends will ICE for now.

Bug: tint:1488
Change-Id: Ied2afa55a338347f427dee98a4076643ac432d9c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86003
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-04-07 13:42:45 +00:00
James Price 2f9e31cefb resolver: Validate increment/decrement statements
These can only be applied to scalar integer references.

These currently cannot be used in a for-loop initializer.

Bug: tint:1488
Change-Id: I218c438c573ff3f5917d058718d12603f9b4057f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86002
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-04-07 13:42:45 +00:00
James Price ebe9741d0c ast: Add an IncrementDecrementStatement node
Bug: tint:1488
Change-Id: I9b307a7b53348055af873c137ad6eebbe1dbe5b0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86001
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-04-07 13:42:45 +00:00
Corentin Wallez b28d6c8e1c Remove lintcpp from presubmits since it fails on all Dawn files
Also fixes some other lint issues.

Bug: dawn:1339
Change-Id: I19a212218db3249191deedc671fc6e36991ecad8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86061
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
2022-04-07 11:36:06 +00:00
Ryan Harrison e87ac76f7d Merge remote-tracking branch 'tint/main' into HEAD
Integrates Tint repo into Dawn

KIs:
- Building docs for Tint is turned off, because it fails due to lack
  of annotations in Dawn source files.
- Dawn CQ needs to be updated to run Tint specific tests
- Significant post-merge cleanup needed

R=bclayton,cwallez
BUG=dawn:1339

Change-Id: I6c9714a0030934edd6c51f3cac4684dcd59d1ea3
2022-04-06 15:37:27 -04:00
Antonio Maiorano a730eb738e Add option to auto generate bindings for external textures
With this change, the backend sanitizers always run the
MultiplanarExternalTexture transform. If the new option is enabled, it
auto-generates bindings for this transform.

This change also enables this auto-generation for the Tint commandline
application, as well as for the fuzzers.

Bug: chromium:1310623
Change-Id: I3c661c4753dc67c0212051d09024cbeda3939f8c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85542
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-04-06 13:57:54 +00:00
Stephen White b7e560dea0 GLSL: fix "uniform" qualifier on texture parameters.
Textures as function parameters should not have the "uniform"
qualifier. Fixed by handling StorageClass::kUniformConstant the
same as StorageClass::kUniform, and removing the unconditional
"uniform" qualifier output. (Global texture variables have
StorageClass::kUniformConstant set, while function parameters don't.)

Change-Id: I9d380550ac4554917527ff330171a76a90a290e8
Bug: tint:1492
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85820
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-04-05 18:51:15 +00:00
James Price 0e1f57cbc2 glsl: Implement compound assignment
Use the ExpandCompoundAssignment transform to convert compound
assignments to regular assignments.

Bug: tint:1325
Change-Id: I0567131aa7c6b4beb6e25c0c6c559795e9c58c19
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85286
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-31 22:30:10 +00:00
James Price 16eeff387c spirv: Implement compound assignment
Use the ExpandCompoundAssignment transform to convert compound
assignments to regular assignments.

Bug: tint:1325
Change-Id: I193a09815836755bc1f7138fe1947be39f7b7206
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85285
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: James Price <jrprice@google.com>
2022-03-31 22:30:10 +00:00
James Price 508a9660a5 hlsl: Implement compound assignment
Use the ExpandCompoundAssignment transform to convert compound
assignments to regular assignments.

Bug: tint:1325
Change-Id: Ic843964ec24d8a2f00f801823f8f8bbf1c6fab5c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85284
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-31 22:30:10 +00:00
James Price 60107e7435 msl: Implement compound assignment
Use the ExpandCompoundAssignment transform to convert compound
assignments to regular assignments.

Bug: tint:1325
Change-Id: I960bf6cd0ec3490cd58685a7c13b6a7c86395080
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85283
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-31 22:30:10 +00:00
James Price b9b6e69631 Add ExpandCompoundAssignment transform
This transform converts compound assignment statements into regular
assignments, hoisting LHS expressions and converting for-loops and
else-if statements if necessary.

The vector-component case needs particular care, as we cannot take the
address of a vector component. We need to capture a pointer to the
whole vector and also the component index expression:

// Before
vector_array[foo()][bar()] *= 2.0;

// After:
let _vec = &vector_array[foo()];
let _idx = bar();
(*_vec)[_idx] = (*_vec)[_idx] * 2.0;

Bug: tint:1325
Change-Id: I8b9b31fc9ac4b3697f954100ceb4be24d063bca6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85282
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-31 22:30:10 +00:00
James Price 555c256344 wgsl: Add support for compound assignment
Implemented in both the reader and writer with E2E tests. Other
backends detect compound assignment and ICE for now.

Bug: tint:1325
Change-Id: Ie3f51e03627a38b12bd1513c4bcf1bebb3282863
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74363
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-31 22:30:10 +00:00
James Price c022ff5b49 resolver: Validate compound assignment statements
Reuse the logic for resolving binary operator result types that was
implemented for binary expressions. This validates that the LHS and
RHS are compatible for the target operator. We then try to match the
resolved result type against the LHS store type.

Bug: tint:1325

Change-Id: If80a883079bb71fa6c4eb5545654279fefffacb4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/74362
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-31 22:30:10 +00:00
James Price 4924186bbd ast: Add a CompoundAssignmentStatement node
Bug: tint:1325
Change-Id: I6b5024fd81cd02119d9520e72ab4bdf14eafc3c2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85280
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2022-03-31 22:30:10 +00:00
Ryan Harrison 9d76aa7424 Add proxies for Tint targets used by Chromium
This will ease rolling Dawn into Chromium, once Tint is merged in

BUG=dawn:1343

Change-Id: I53fa7b82a001ab3351f5366e8e045090c0fdb49b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/85380
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2022-03-31 19:54:15 +00:00
Antonio Maiorano b349710476 HLSL: workaround FXC error "continue cannot be used in a switch"
Added a new transform::RemoveContinueInSwitch that replaces continue
statements in switch cases with setting a bool variable, and checking if
the variable is set after the switch to continue.

Bug: tint:1080
Change-Id: I3c0a6c790e1bb612fac3f927a4bd5beb2d0d4ed1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/84960
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-03-31 15:02:25 +00:00
Antonio Maiorano c2e9bb785a Factor out GetInsertionPoint to transform/utils
This function was copy-pasted in two transforms, and will be used in the
next one I'm writing.

Bug: tint:1080
Change-Id: Ic5ffe68a7e9d00b37722e8f5faff01e9e15fa6b1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85262
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-03-30 20:11:35 +00:00
James Price e6c76095fc builtins: Add smoothstep, deprecate smoothStep
Bug: tint:1483
Change-Id: I8702933312a7e46f82745f232214910433485fe5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85261
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-03-30 17:57:39 +00:00
James Price 2ec98d961c builtins: Use commas for struct members in tests
The test files were already updated manually in a previous change, so
we just need to update the template file to match.

Bug: tint:1475
Change-Id: I6f1b3d3a7a3df014b58e67ec2645b1dfcc275de1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85260
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2022-03-30 17:57:39 +00:00
Antonio Maiorano 66d6668372 Implement discard semantics
Implement new transform UnwindDiscardFunctions that replaces discard
statements with setting a module-level bool, adds a check and return for
this bool after every function call that may discard, and finally
invokes a single function that executes a discard from top-level
functions.

Regenerated tests and remove HLSL ones that used to fail FXC because it
had difficulty with discard.

Bug: tint:1478
Bug: chromium:1118
Change-Id: I09d680f59e2d5d0cad907bfbbdd426aae76d4bf3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/84221
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-03-28 20:51:32 +00:00
Ryan Harrison 3374f43c31 Normalize DEPS to ease merging with Dawn
- Format specific targets to have the hash in the target rule instead
  of a variable.
- Only have the base part of the URL in a variable
- Use vulkan-deps instead of individual DEPS (spirv-tools,
  spirv-headers & glslang)

BUG=tint:1481

Change-Id: I871a656e26050698da2c77f4f39fec94a9c4f8a4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/84723
Reviewed-by: David Neto <dneto@google.com>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2022-03-28 18:01:02 +00:00
Antonio Maiorano 9e5484264a Implement mixed vector-scalar float % operator
W3C consensus on https://github.com/gpuweb/gpuweb/issues/2450
Spec change: https://github.com/gpuweb/gpuweb/pull/2495

Bug: tint:1370
Change-Id: I85bb9c802b0355bc53aa8dbacca8427fb7be1ff6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/84880
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2022-03-28 14:36:31 +00:00
James Price 3b671cb377 wgsl: Separate struct members with commas
Use of semicolons is still supported, but deprecated.

Also updates the parsing methods for structures to better match the
WGSL grammar.

Bug: tint:1475
Change-Id: I7675ba42c13f91080b0ac173c352e0092021f80b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/84380
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2022-03-28 14:31:22 +00:00