Commit Graph

6 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 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 e6d171ac66 writer/hlsl: Implement atomics
Storage buffers are emitted as `ByteAddressBuffer`s in HLSL, so we have to jump through hoops to support atomic ops on storage buffer atomics.
Workgroup atomics are far more conventional, but very little code can be shared between these two code paths.

Bug: tint:892
Change-Id: If10ea866e3b67a093e87aca689d34065fd49b705
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54651
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-06-18 18:56:13 +00:00
Ben Clayton 6a77236d8c intrinsics.def: Add atomic intrinsics
Change-Id: I26a9ce9e1978aa2542ce2b3f17c9f5861e556a8a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54657
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-06-18 18:56:13 +00:00