Commit Graph

7 Commits

Author SHA1 Message Date
James Price a5d73ce965 transform/shader_io: Generate a wrapper function
This is a major reworking of this transform. The old transform code
was getting unwieldy, with part of the complication coming from the
handling of multiple return statements. By generating a wrapper
function instead, we can avoid a lot of this complexity.

The original entry point function is stripped of all shader IO
attributes (as well as `stage` and `workgroup_size`), but the body is
left unmodified. A new entry point wrapper function is introduced
which calls the original function, packing/unpacking the shader inputs
as necessary, and propagates the result to the corresponding shader
outputs.

The new code has been refactored to use a state object with the
different parts of the transform split into separate functions, which
makes it much more manageable.

Fixed: tint:1076
Bug: tint:920
Change-Id: I3490a0ea7a3509a4e198ce730e476516649d8d96
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60521
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-08-04 22:15:28 +00:00
James Price 5c61d6d12c msl: Fold &* when converting module-scope vars
This transform was previously converting this code:
```
var<private> v : f32;
fn foo() {
  bar(&v);
}
```

into this:
```
fn foo(vp : ptr<private, f32>) {
  bar(&*vp); // Invalid, since ptr args must be &ident
}
```

Fixed: tint:1086
Change-Id: Ic9efafa219c89a11a4d6e1d11fc69b3c0b9a5464
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60520
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
2021-08-04 19:18:38 +00:00
Ben Clayton 89a0bde59c transform: Optimize ZeroInitWorkgroupMemory for arrays
Spread the array zeroing across as many workgroup invocations as possible.

Bug: tint:910
Change-Id: I1cb5a6aaafd2a0a4093ea3b9797c173378bc5605
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60203
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-07-30 14:08:06 +00:00
Ben Clayton 053559d051 intrinsics: Add new struct form of modf(), frexp()
Implement these for all the writers.
SPIR-V reader not implemented (the old overloads weren't implemented either).

Deprecate the old overloads.

Fixed: tint:54
Change-Id: If66d26dbac3389ff604734f31b426abe47868b91
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59302
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
2021-07-23 16:43:01 +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
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
Ben Clayton 433b4ec60d test: Generate more permutations for pointers
Instead of just generating pointers to functions, generate pointers to all permuted storage types and accesses.

Change-Id: I930b20150d823877eaf72dd7cac850078fe22f35
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54656
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-06-18 18:56:13 +00:00