Commit Graph

268 Commits

Author SHA1 Message Date
Ben Clayton 1b03f0a07a reader/wgsl: Generate ForLoopStatements
Instead of LoopStatements.

Update the writers to handle these.

Fixed: tint:952
Change-Id: Ibef66e133224810efc28c224d910b5e21f71f8d6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57203
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-07-08 21:23:33 +00:00
Ben Clayton 03c8393213 [writer/msl]: Implement modf and frexp
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/1480
https://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>
2021-07-08 21:21:27 +00:00
Ben Clayton e4fd4a2ecd test/intrinsics/gen: Use '0' for level parameters
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>
2021-07-08 21:04:53 +00:00
Brandon Jones 79fae01483 Remove texture_external overload for textureSample
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>
2021-07-08 20:58:18 +00:00
Ben Clayton 5d922d02fc Revert "writer/hlsl: Special case negative zero"
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>
2021-07-08 16:49:33 +00:00
Ben Clayton 70a3fa1ee9 [intrinsics] rm f32 overloads of reflect, faceForward
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>
2021-07-08 15:08:53 +00:00
Ben Clayton a7392fbd8a [test]: Add test case for tint:369
Fixed: tint:369
Change-Id: Ib5f6c84bc8e0f43ab0034048ab1517335ae2d7bc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57200
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-07-08 12:00:31 +00:00
Ben Clayton 97bddeee20 [transform] Add ForLoopToLoop
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>
2021-07-08 10:00:17 +00:00
Ben Clayton 2ba8315b02 [test]: Add some test cases for for-loops
Bug: tint:952
Change-Id: I156e29a74ce3942a39f25dc5bfb3d5467e206fce
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57201
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-07-08 10:00:17 +00:00
Ben Clayton 1e153613eb [utils]: Add TINT_DEFER()
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>
2021-07-08 10:00:17 +00:00
Ben Clayton 26b6edc545 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>
2021-07-07 11:19:20 +00:00
Ben Clayton 9545fb76b6 Remove depreated APIs and WGSL
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>
2021-07-06 10:20:19 +00:00
Ben Clayton 692fc20797 [writer/hlsl,msl] Correctly generate inf and nan literals
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>
2021-07-06 09:43:49 +00:00
Ben Clayton 5d8eb4a758 reader/wgsl: Improve reserved keyword error messages
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>
2021-07-05 21:48:37 +00:00
Ben Clayton b4ff73e250 [hlsl] transform: Zero init arrays with a loop
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>
2021-07-05 17:18:16 +00:00
Ben Clayton b0455217fa Add refract intrinsic
See: https://github.com/gpuweb/gpuweb/pull/1901

Bug: tint:950
Change-Id: I6f00ab753a2ddf2374352ddf636e1abfebe86ba7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56777
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-07-05 16:47:37 +00:00
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 5e607680e7 transform: Add LoopToForLoop
A Transform that attempts to convert WGSL `loop {}` statements into a for-loop statement.
For-loops cause less broken behavior with FXC than our current loop constructs.

Bug: tint:952
Change-Id: I0b7b1dbec9df4c004b0419d3feae53a195ec79bb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56767
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-07-02 22:17:25 +00:00
Ben Clayton 75cd59261d transform: Add FoldTrivialSingleUseLets
This transform is intended to clean up the output of the SPIR-V reader, so that we can pattern match loops that can be transformed into a for-loop.

Bug: tint:952
Change-Id: Iba58e4e1f6e20daaf7715e493df53346cdb7c89f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56766
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
2021-07-02 21:15:44 +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 65cd25951a ast: Add ForLoopStatement node
Currently entirely unused.

Bug: tint:952
Change-Id: I3ba2823024b81e927d8fe8a80fac4f82c02eac3e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56761
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-07-02 19:27:42 +00:00
James Price 37cabbb468 validation: structures cannot be empty
Fixed many tests that had empty structures.

Change-Id: Id91312afa39a6293426f99d0dd12578dba46aa61
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56621
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-07-01 08:13:41 +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 fb4e751258 test: Add tests to verify variables are zero initialized
Bug: tint:938
Fixed: tint:759
Change-Id: I5794d7f40ec154c55240b163316ed45c7f14b190
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56547
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-06-30 15:59:40 +00:00
Ben Clayton 71a1f58537 test: move test/var files to test/var/uses
These test primarily test emission of the variables based on transitive function call usage.

Change-Id: I0f64cb6496ed1238000cb8a6c97a1a445de0ab41
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56546
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-06-30 15:58:50 +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 0273f1a604 transform: Rename BoundArrayAccessors to Robustness
We will want this transform to do more bounds and argument sanitization.

Bug: tint:748
Change-Id: I38cb9623622e9f5ab85d8cd420d669ca6be77099
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56543
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-06-30 13:23:36 +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
James Price d18f2e0d6e writer/spirv: Do not add Flat to fragment outputs
Use the sanitizer to add the decoration only to the variables that are
vertex outputs and fragment inputs.

Bug: dawn:963, tint:746
Change-Id: I1b91cf3550fb3c6f583d69e822444534a576e0cd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56460
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
2021-06-29 18:05:25 +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
James Price 5ea0fe00bf writer/spirv: Add Flat decoration to integers
Vulkan requires that shader inputs/outputs that are integers must be
decorated with Flat.

Bug: tint:746, dawn:956
Change-Id: I648451b9aa559d08415bada904dee5f9d1e4e60f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56400
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
2021-06-29 13:36:05 +00:00
Ben Clayton f2ec7f38e5 writer/msl: Implement atomics
Common logic between the HLSL, WGSL and MSL writers has been moved into
the TextGenerator base class.

Fixed: tint:892
Change-Id: I0f469516947fe64817ce6251e436da74e5e176e8
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56068
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
2021-06-29 11:53:15 +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
James Price 077fe64b11 intrinsics: Add missing select() overload
WGSL supports select() with vectors, where the condition is a
scalar. To support this in SPIR-V versions older than 1.4, we need to
splat the condition operand to a vector of the same size as the
objects.

Fixed: tint:933
Change-Id: I571af46e74cd7bb24093524ccfed25a3ed612676
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56340
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-29 08:45:34 +00:00
James Price c7aa21e265 writer/spirv: Implement interpolate attributes
Add the SampleRateShading capability if the sampling type is `sample`.

Bug: tint:746
Change-Id: I20fb25913f5c0919b6d16a9d0e9fc8b1551ff7ea
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56247
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-06-28 23:04:43 +00:00
James Price 0dd41c62cf writer/hlsl: Implement interpolate attributes
Bug: tint:746
Change-Id: I3133a756d1fe830c0baf45a1251acea9511d92b1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56246
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-06-28 23:04:43 +00:00
James Price f8e0b7dbf1 writer/msl: Implement interpolate attributes
Bug: tint:746
Change-Id: Ia96da94b948c0e2c6d99452d5e152113e2af1264
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56245
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-06-28 23:04:43 +00:00
James Price 545f4e0f77 writer/wgsl: Implement interpolate attributes
Add E2E tests to cover all of the parameter combinations.

Mark the attribute as unimplemented in the other backends.

Bug: tint:746
Change-Id: I86881ff0b224fe93670db42473341ae185eeabdd
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56244
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-06-28 23:04:43 +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 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
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