Commit Graph

57 Commits

Author SHA1 Message Date
James Price 537ed0bbd5 Update expected MSL for bug 926 E2E test
We now generate valid code for this.

Change-Id: I9402c6aa32365fca5683e91b3fa345ed7d3e34ed
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56622
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-05 15:56:32 +00:00
Ben Clayton 4135ea55eb writer/hlsl: Don't wrap arrays in structures
FXC has trouble dealing with these.
This was originally added to handle returning arrays as structures.
HLSL supports typedefs, which is a much simpiler solution, and doesn't upset FXC.

Bug: tint:848
Bug: tint:904
Change-Id: Ie841c9c454461a885a35c41476fd4d05d3f34cbf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56774
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-07-05 15:20:57 +00:00
Ben Clayton 106ac290e6 Remove accidental commit
Change-Id: I3a81cec7e78a61f841be9e9f48b41d86ee5b1ca5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56773
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-07-05 14:18:37 +00:00
Ben Clayton 0e41747281 writer/hlsl: Emit for-loops where possible.
Use the new transforms to try and simplify loops into for-loops.
Emit loops when the initialiser, condition and continuing are simple enough to do so.

Bug: tint:952
Change-Id: I5b3c225b245ffa72996abf6a70f52a9cd25b748e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56772
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-07-02 22:17:25 +00:00
Ben Clayton 9ad49e43c1 test: Add more reported bug cases
Bug: tint:943
Bug: tint:948
Bug: tint:949
Change-Id: Ib511b69d9e4308b106de2c191bae91f5cade2507
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56770
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-07-02 22:17:25 +00:00
Ben Clayton 3124d43fda writer/hlsl: Use unsigned indices for UBOs
These indices were a mix of signed and unsigned.
Modulus on the signed integers was producing FXC warnings about performance.

Change-Id: Ib82f4296199a09d2f03be8b06314feefce0022e2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56765
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-07-02 19:27:42 +00:00
Ben Clayton 2bb45389b7 writer/hlsl: Zero initialize with (T) 0
For structures and arrays.
This behaves identically to the per-element zero-initialization, but can be significantly less verbose.

Change-Id: I380ef86f16c2b3f37a9de2820e707f368955b761
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56764
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-07-02 19:27:42 +00:00
Ben Clayton 885488da41 writer/msl: Use UniqueIdentifier() for padding field names
UniqueIdentifier() will generate a program-global unique symbol.

MslGeneratorImplTest.AttemptTintPadSymbolCollision tests for collisions with the field names.
TextGeneratorTest.UniqueIdentifier_ConflictWithExisting tests for collisions between general symbols.

Fixed: tint:654
Change-Id: If2ba75d04ff0e2a9975e878596ac114d51adcd46
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56580
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-06-30 16:01:40 +00:00
Ben Clayton 5e2d8af6ad test: Add missing .expected files
Theses were missing from https://dawn-review.googlesource.com/c/tint/+/56140

Change-Id: Iece1c69923024da2ce9473e205c18eb9568872b9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56548
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-06-30 15:06:00 +00:00
Ben Clayton 51b9da45c8 writer/hlsl: Fix level packing for textureLoad()
This was spectacularly broken. Caught by CTS.

Change-Id: Iebf9dd5934be8ef4ec4217d60d5691aee73f5ea3
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56501
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-30 08:51:36 +00:00
Antonio Maiorano b293f51f83 Implement FXC workaround for vector access in loops resulting in failed loop unrolling
When indexing into vectors in a loop, FXC sometimes fails to determine
the max number of iterations when attempting to unroll the loop,
resulting in "error X3511: forced to unroll loop, but unrolling
failed.". We work around this by calling a function that sets the input
value at the input index into an inout vector. This seems to nudge FXC
enough for it to determine the number of loop iterations to unroll.

Bug: tint:534
Change-Id: I52cb209be29fcad8fbb91283c7be8c6e22e00656
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56140
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-06-29 22:07:44 +00:00
Sarah e6cb51e715 validation: compute shader must include 'workgroup_size' in its attributes
Bug: tint:884
Change-Id: If96c6df3247fee142a779117fa26d006afd4f7ef
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55680
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-06-29 18:39:44 +00:00
David Neto 91622e3853 spirv-reader: flatten output matrix, array, struct
Bug: tint:912
Change-Id: Iebbcb7ea8d870cccadad7dd1ce8aaccf8965b370
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56301
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Auto-Submit: David Neto <dneto@google.com>
2021-06-29 14:38:56 +00:00
Ben Clayton 4b7af8d2c9 writer/spirv: Handle terminators in BlockStatements
Fixed: tint:922
Change-Id: Ib3815ada8bcf2d4c1f8c86d4178cd088ba071c6c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56280
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-06-29 10:23:26 +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
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
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 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
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
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
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
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 663271dca4 writer/msl: Fix continuing block emission
Inline the `continuing` block in the places where `continue` is called.

Simplifies the emission, and fixes emission of `let` statements in the loop.

This fix matches the same approach in writer/hlsl.
See: https://dawn-review.googlesource.com/c/tint/+/51784

Fixed: tint:833
Fixed: tint:914
Change-Id: If4d8cde62dfaf8efa24272854ca7ff5edc0a8234
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55341
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-06-21 08:49:27 +00:00
Ben Clayton c15baf695d test: Add bug case for tint:914
Bug: tint:914
Change-Id: Id17b675e947b170e460c415c15d5d75f311e65b0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55247
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-06-19 17:34:35 +00:00
Ben Clayton 0f916164ae writer/hlsl: Add missing parenthesis around UBO ternary op
Bug: tint:913
Change-Id: I2edbab363cb03e6ce64b5c6bddf184bf92438521
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55340
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-19 08:18:50 +00:00
Ben Clayton 165512c57e writer/hlsl: Emit UBO as an array of vector
Instead of a ConstantBuffer.

HLSL requires that each structure field in a UBO is 16 byte aligned.
WGSL has much looser constraints with its UBO field alignment rules.

Instead generate an array of uint4 vectors, and index into this, much
like we index into [RW]ByteAddressBuffers for SSBOs.

Extend the DecomposeStorageAccess transform to support uniforms too.
This has been renamed to DecomposeMemoryAccess.

Change-Id: I3868ff80af1ab3b3dddfbf5b969724cb87ef0744
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55246
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-06-18 21:15:25 +00:00
James Price 567f2e4f3b transform/msl: Run InlinePointerLets and Simplify
This will be relied on by the upcoming arrayLength transform.

Update test expectations.

Change-Id: Ib74b647abcd6f4393f9899ce40bbf06f6e53e7f4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/55180
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-06-18 09:47:23 +00:00
David Neto 17287fcf1a spirv-reader: Set workgroup size, but not specializable
The WorkgroupSize builtin decoration applies to a composite constant.
Because WGSL does not yet support specializable constants for this,
use the *default* values for that SPIR-V spec constant.

Update end-to-end test expectations.

Fixed: tint:503
Change-Id: I012b316d13544ab9282e3276b58906327adab133
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/41960
Auto-Submit: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
2021-06-17 22:40:43 +00:00
David Neto 1e19b55d19 spirv-reader: switch to HLSL-style pipeline IO
- When storing to sample_mask output, write to the 0th element
- Only make a return struct if it has members
- Adjust type signedness coercion when loading special builtins.
- Adapt tests

- Update expectations for end-to-end tests

- Handle sample_mask with stride
  Input variables normally don't have layout. But they can have it
  up through SPIR-V 1.4.
  Handle this case in the SPIR-V reader, by seeing through the
  intermediate alias type created for the strided array type.

Bug: tint:508
Change-Id: I0f19dc1305d3f250dbbc0698a602288c34245274
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54743
Auto-Submit: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-06-17 09:10:04 +00:00
Sarah b6fdcc54df transform: remove VarForDynamicIndex transform.
Dynamic indexes are limited to references to matrices and arrays
https://github.com/gpuweb/gpuweb/pull/1801

Bug: tint:867
Change-Id: I114daa053c8a4ffd23ce784ac4538567a551cc21
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54701
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Sarah Mashayekhi <sarahmashay@google.com>
2021-06-16 17:42:53 +00:00
Ben Clayton d47eb3a965 writer/hlsl: Generate padding for UBO padded structs
Combined with the new PadArrayElements transform, arrays with strides
are now correctly emitted.

Fixed: tint:182
Fixed: tint:895
Change-Id: I26a1be94dee6e4c9d9747c8317a932fc1fb3c810
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54640
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-06-16 09:50:11 +00:00
Ben Clayton 92b1991271 test: Add case for tint:870
Also update SKIP reasons for DXC failures.

Bug: tint:870
Change-Id: I90b1af238249656fb02dfecbecf7f9258730e963
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54580
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-06-16 09:50:11 +00:00
Ben Clayton 677437d650 resolver: Reenable VS validation for returning position
Fixed: tint:730
Change-Id: I7d5ebeffe2d522182d07f554a671bebab1cce2e6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54420
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-06-16 09:50:11 +00:00
Ben Clayton 7e00263c01 wgsl: Remove [[access]] and [[offset]] decorations
These have been deprecated, and their usages in Dawn, CTS and samples have been updated.

Fixed: tint:846
Change-Id: I74b831fd5be2e7ca02e8208835eac8beddcef9af
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54325
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-06-16 09:19:36 +00:00
Ben Clayton 9ef52ffd8c writer/hlsl: Use the WrapArraysInStructs transform
Fixes issues with using arrays as function return types.

Fixed: tint:848
Change-Id: Iee8af0f2cea9d19e448176446c6599be2bd32316
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54321
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-06-16 09:19:36 +00:00
Ben Clayton 0597a2b51b Add transform/WrapArraysInStructs
And replace the MSL writer's logic to do this with the transform.

We need to do the same thing in HLSL, and in the future GLSL too.

Partially reverts fbfde720

Change-Id: Ie280e011bc3ded8e15ccacc0aeb12da3c2407389
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54242
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-06-16 09:19:36 +00:00
Ben Clayton 5d2f34ecf2 writer/hlsl: Simplify emission logic, clean up output
And fix issues where global variables would not be emitted unless they were transitively referenced by an entry point.

This change requires crbug.com/tint/697 to be fixed before landing.

Change-Id: I712bd9d369e08c9a3cdfb0f114c3609584f91f28
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54241
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-06-16 09:19:36 +00:00
Ben Clayton 3628949efc test: Add bug cases taken from monorail
Some now pass, some still fail.

If we fix bugs and they begin to pass, we have a better chance of noticing and marking the issues as fixed.

Change-Id: I7278f960967a570ccde8865dcf2aa580235559bf
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54062
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-06-10 18:49:14 +00:00
Ben Clayton 0aa7edbbd5 transform/spirv: Use InlinePointerLets & Simplify
arrayLength() will take a pointer to a storage buffer array.
This pointer may pass through function scoped let statements.
To make this intrinsic easier to generate, inline the pointer lets and
remove chains of &*&*.

Bug: tint:806
Change-Id: Ib2c79a9c38cba7391cbb4313986af9a72b0f0435
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54060
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
2021-06-10 17:34:44 +00:00
Ben Clayton 1858854f7e Add optional access to ptr<>
This also completes the work to resolve the access controls for each
storage type.

Fixed: tint:846
Change-Id: Iab24057ec14620a2978ec63c4a91ba12d1bc6e9b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53381
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-06-04 22:17:37 +00:00
Ben Clayton 93e8f527ee wgsl: Deprecate [[access]] decorations
Handle access control on var declarations instead of via [[access]]
decorations. This change does the minimal work to migrate the WGSL
parser over to the new syntax. Additional changes will be needed
to correctly generate defaulted access qualifiers, as well as
validating access usage.

The [[access]] decorations are still supported by the WGSL parser,
with new deprecated warnings, but not for aliases. Example:
   var x : [[access(x)]] alias_to_struct;

Making this work is far more effort than I want to dedicate to backwards
compatibility, and I do not beleive any real-world usage will be doing
this.

Still TODO:
* Adding access control as the optional, third parameter to ptr<>.
* Calculating default accesses for the various storage types.
* Validating usage of variables against the different accesses.

Bug: tint:846
Change-Id: If8ca82e5d16ec319ecd01f9a2cafffd930963bde
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53088
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-06-04 20:41:47 +00:00
James Price 7697c31e84 writer/msl: Emit builtins as parameters
Add a config parameter for the CanonicalizeEntryPoint transform that
selects between emitting builtins as parameters (for MSL) or struct
members (for HLSL).

This fixes all of the shader IO issues in Tint's E2E tests for MSL.

Fixed: tint:817
Change-Id: Ieb31cdbd2e4d96ac41f8d8515fd07ead8241d770
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53282
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-06-04 14:40:28 +00:00
Ben Clayton a70c14dbce main: Replace --dawn-validation with --validate
Performs output validation with spirv-val for SPIR-V (as before), HLSL
validation with DXC, and MSL validation with the Metal Shader Compiler.

Disable HLSL tests that fail to validate

Bug: tint:812
Change-Id: If78c351b4e23c7fb50d333eacf9ee7cc81d18564
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51280
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-06-02 21:02:34 +00:00
James Price 94ac078990 writer/msl: Wrap each array type in a struct
This allows them to be used in various places that WGSL allows, such
as function return types and parameters, and as the type of the RHS of
an assignment.

Fixed: tint:814
Fixed: tint:820
Change-Id: Idb6a901b9a34e96bb9733cc158191e7b3bafaa0e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52844
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@google.com>
2021-06-02 17:23:03 +00:00
James Price cbd3bbc6d7 Disable MSL tests that fail to validate
Change-Id: Iaf31627798a83625a075e529aa3886cf84b164b1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/52040
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-05-27 16:48:57 +00:00
James Price 5102f87e38 writer/msl: Add parentheses for member accesses
The LHS should be wrapped in parentheses if it has lower precedence
than the access. This fixes issues with pointer dereferences followed
by member accesses, where we were previously generating *a.b.

Fixed: tint:831
Change-Id: I8a194ad4f54c80a01c24eb983ec8064037575216
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51963
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-05-27 14:15:47 +00:00
James Price 7a47fa8495 writer/msl: Handle private and workgroup variables
Add a transform that pushes these into the entry point and then passes
them by pointer to any functions that need them.

Since WGSL does not allow non-function storage class at
function-scope, add a DisableValidation attribute to bypass this
check.

Fixed: tint/726
Change-Id: Ic1f4cd691a54c19e77a60e8ba178508e4249bfd9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51962
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-05-26 15:41:02 +00:00
Ben Clayton ed86bf99b0 Add transform::Simplify
Performs basic peephole optimizations on the AST.

Use in transform::Hlsl.

Required to have the DecomposeStorageAccess transform operate correctly with the output of InlinePointerLets transform, specifically when declaring `let` pointer expressions to storage buffers.

Fixed: tint:221
Fixed: tint:492
Fixed: tint:829
Change-Id: I536390921a6492378104e9c3c100d9e761294a27
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51921
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2021-05-21 21:01:23 +00:00
Ben Clayton ada560b289 writer/hlsl: Fix continuing block emission
Inline the `continuing` block in the places where `continue` is called.

Simplifies the emission, and fixes emission of `let` statements in the loop.

Also fix random indenting of intrinsic functions.

Fixed: tint:744
Fixed: tint:818
Change-Id: I06994dbc724bc646e0435a1035b00760eaf5f5ab
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51784
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-05-20 21:31:37 +00:00