Replace the ShouldRun() method with Apply() which will do the
transformation if it needs to be done, otherwise returns
'SkipTransform'.
This reduces a bunch of duplicated scanning between the old ShouldRun()
and Transform().
This change also adjusts code style to make the transforms more
consistent.
Change-Id: I9a6b10cb8b4ed62676b12ef30fb7764d363386c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107681
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Previously Hashmap used to internally use a Hashset which held entries
of key-value pairs. This was cute, but meant that a Hashset held mutable
entries, which was a bag-of-bugs waiting to happen (change the entry to
hash as something different and you're now in an entirely broken state).
Pull the complex bits of Hashset out to HashmapBase, and have both
derive from that. I've opted for inheritance over composition here to
reduce the amount of structure chasing you'd have to do without
debugger pretty-printers.
Change-Id: I99e72244b69206a994edabfefd0e28d5d74d08d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108240
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Involves expanding the source range of a variable declaration so we can point at something that can include the 'const'.
Fixed: tint:1740
Change-Id: Ie8f784de34a1792002aaa708c1b77053be54f1b5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108120
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Now that expressions can only ever have the `Next` behavior,
short-circuiting operators will always reconverge.
Change-Id: Ib9fe4c774191b8a304fa7f7a6eafdfa6c6e6f18a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108202
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
This reverts commit 7cd8db1155.
Reason for revert: Breaking the Skia roll.
Original change's description:
> Add GN build option to build using generated files.
>
> This CL hooks the generated files into the GN build
> behind a `tint_build_use_generator` flag.
>
> Change-Id: I4926b2c9c1a349f26be8a1f8a4508e1e31dab813
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108041
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Ben Clayton <bclayton@chromium.org>
> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
TBR=dsinclair@chromium.org,bclayton@google.com,bclayton@chromium.org,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: I3b920791bc2b6d22d9cbeb1310a2e89fbd1e8cd1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108205
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Instead of using the tools/run script this CL updates CMake
to directly invoke go run. This should work around issues
with multiple writers of the gen binary and fixup windows issues.
Change-Id: Ie27f45a1d132e9ec100cad709bb92da8558b4fb3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108045
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
A new HoistToDeclBefore::InsertBefore() overload that takes a statement
builder. Required for supporting multiple clones.
Remove Apply() - it was API smell that wasn't needed.
Spring-clean the implementation
Change-Id: If448d2e1945ad6d988d1bdb30487d89efced2f0e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104043
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Invalid values to @binding(), @group() and @location() would fail resolving without an error diagnostic. This later triggers and ICE.
Refactor duplicate @location resolving in 4 places to a single method.
Canonicalize the diagnostic messages for attributes.
Remove a bunch of TODOs
Bug: chromium:1380212
Bug: tint:1633
Change-Id: Id2cc6ba4b807f12f350a2a31ef87fa0f185b64c3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108144
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This CL make transform AddBlockAttribute always try to wrap types used
by buffer variables into a struct, in order to generate valid GLSL code
for assigning one buffer struct variable to another buffer struct
variable.
Fixed: tint:1735
Change-Id: I009d8a9ca7ecea1dc0ad6164275c964a18acb33f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108023
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
When emitting the if true/false blocks we attempt to set the merge
target if the start block hasn't branched. This isn't right, as if the
block branched to other control flow, then that isn't the end of the
flow chain for that branch. We have to look at the current branch
target, and, if it exists, branch that to the if merge block.
Bug: tint:1718
Change-Id: Ifcafc4dd12c805efbee9d1dbcbc42c6add8f06a9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107861
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This CL adds the ability to dump an IR graph to a dot file. The
`--dump-ir-graph` option is added to the main tint command. The IR code
is moved behind a TINT_BUILD_IR flag in order to allow the GN build to
continue to build the tint program.
Bug: tint:1718
Change-Id: I0953fe2a59a34c21bb6cd288cb90e9d0298af793
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107860
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL adds the ability to convert a for statement into a loop control
flow node.
Bug: tint:1718
Change-Id: Ibd55ae3b202518d3362267eaa1f507dce6a9fe56
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107804
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This CL adds `while` statement support into the IR builder, converting
them into loop flow nodes.
Bug: tint:1718
Change-Id: I6dbaa24a0082463281dc933f02805169836fedd6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107803
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL hooks the generated files into the GN build
behind a `tint_build_use_generator` flag.
Change-Id: I4926b2c9c1a349f26be8a1f8a4508e1e31dab813
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108041
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This CL adds `fallthrough` support to the IR building. Fallthrough is
deprecated but needs to be supported until removed from Tint.
Bug: tint:1718
Change-Id: I52ce4cc9953384a450ad09422b2ba38943284a42
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107802
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This Cl adds an option to cmake to generate the intrinsic files
as part of the buid.
Change-Id: I785fbaa57b6d3b3ecd16e36b2f2baaa5da3cc9d9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108000
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Renames all symbols
Add a test for tint:1725
Bug: tint:1725
Change-Id: Idac45c677d15361d76510068ad756e2f9bffacb0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/106880
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This CL updates the IR builder to create control flow nodes for
a switch statement and the contained case statements.
Bug: tint:1718
Change-Id: I05b73db11ab14676cc123f436ae5912b1dbee0d5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107801
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This CL updates the flow node to track the nodes which are inbound
to the current target. This allows to fix an issue with a loop,
after a continuing with a break, properly eliminating dead code.
This also allows always providing the merge target for an if, it
just knows if it's disconnected by having zero inbound branches.
Bug: tint:1718
Change-Id: Ia9b9dbc734bf1e9cd0c829093c0cb1e470efb32e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107800
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This CL sets up the basis for the intrinsic file generation. All of
the GN and CMake pieces are setup, but they aren't hooked into the
main build yet. That will be a followup which just enables the
generation in order to allow easy reverting.
Change-Id: Iccac59377076ed6ac66eeaf0be965be2f49bc738
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107981
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This CL fixes up a shadow variable which causes compilation issues
on OSX.
Change-Id: I750423630cc2882d176c5ef304e1e0b4bef133a6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108040
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: Ben Clayton <bclayton@chromium.org>
Describe the peculiare mismatches between Vulkan-flavoured
SPIR-V and WGSL that the SPIR-V Reader has to contend with.
Describe the solution in broad terms.
This is likely incomplete, but a good start.
Change-Id: I76992e9b830169d81cb55c46e849d9ad2f55c6c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/105600
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Timestamp period is also needed by the timestamp-query-inside-passes
feature, which is enabled separately from the timestamp-query feature.
Bug: dawn:1193
Change-Id: I8a1f87f8d7931261b87608306820daefc4c3dc55
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107880
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Hao Li <hao.x.li@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
docs/tint/arch.md states that:
> The input `Program` to the inspector must be valid (pass validation).
So it should not be assumed that the inspector can handle invalid programs.
Bug: chromium:1378999
Change-Id: I780f59ba1117f5eadb461a55947c8e36761ab25f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107688
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
`-o` will emit the files to the given root output directory
`--verbose` will print what's going on, to help with debugging
Omitting these flags will behave as before.
Also consolidate the utils package into fileutils. These were two packages with near identical functionality.
Change-Id: I855dd4b57807fb9239a52e7f357842d4ba2517ee
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107687
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
...to `min(max(e, low), high)` as defined by the WGSL spec.
Fixed: tint:1479
Fixed: tint:1539
Change-Id: I39406d5256a155a781e44bd9d6081ce7a9bf5a68
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107640
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
I got the rules around this wrong. This should be allowed, but the array types cannot compare equal if they are unnamed override-expressions.
Fixed tint:1737
Change-Id: I83dc49703eed015e9c183e804474886da5dad7b9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107685
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
We now use the MergeReturn transform for SPIR-V, which is the only
backend that requires special handling to meet these function call
reconvergence requirements.
Fixed: tint:1627, tint:1726
Change-Id: I25f848f4b9ff0fd301b8a27a220bb09cdb2867ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107364
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>