Commit Graph

10 Commits

Author SHA1 Message Date
Arman Uguray 3549e2ea8c Resolver: Enforce vector constructor type rules
Added enforcement for vector constructor type rules according to the
table in https://gpuweb.github.io/gpuweb/wgsl.html#type-constructor-expr.

This surfaced a number of existing tests that violated some of these
rules or had a type-declaration related bug, so this CL fixes those as
well (these tests either passed the incorrect number of arguments to a
vector constructor or relied on implicit conversions between numeric
types).

Fixed: tint:632
Fixed: tint:476
Change-Id: I8279be3eeae50b64db486ee7a91a43bd94fdff62
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44480
Commit-Queue: Arman Uguray <armansito@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-03-15 21:21:33 +00:00
Ben Clayton 2f9ced0341 Update DEPRECATED comments about offset decorations
Let's keep these for the SPIR-V reader case. The way things currently work is actually nicer than attempting to generate size / align decorations in the SPIR-V reader.

Change-Id: I83087c153e3b3056e737dcfbfd73ae6a0986bd7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44684
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-15 20:34:22 +00:00
Ben Clayton 822fa54d87 writer/wgsl: Fix size / align decoration emission
This was broken by a rebase of the Default Struct Layout change.
This went unnoticed because there was no test coverage for these. Added.

Also replace `[[offset(n)]]` decorations with padding fields.

Bug: tint:626
Change-Id: Iad6f1a239bc8d8fcb15d18a204d3f5a78a372350
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44683
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-15 20:25:12 +00:00
Ben Clayton a75205265e Add src/utils/math.h
Move the RoundUp() and IsPowerOfTwo() methods from Resolver.cc to this file.

Add tests

Change-Id: Ib7af53dfa5e69083ec4fc2484da92a84c9468818
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44682
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-15 13:37:41 +00:00
Ben Clayton d614dd5d12 Implement Default Struct Layout
Implements https://github.com/gpuweb/gpuweb/pull/1447

SPIR-V Reader is still TODO, but continues to function as the offset
decoration is still supported.

Bug: tint:626
Bug: tint:629
Change-Id: Id574eb3a5c6729559382812de37b23f0c68fd406
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/43640
Commit-Queue: Ben Clayton <bclayton@chromium.org>
Reviewed-by: David Neto <dneto@google.com>
2021-03-15 10:43:11 +00:00
Ben Clayton 5fb87dd915 Resolver: Validate if() conditions are bools
Fixed: tint:317
Change-Id: Ica56dfb12d6b1a45e61d0d791f723414b464da5f
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44163
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 15:17:28 +00:00
Ben Clayton c7dcbae41c Resolver: Place into a resolver namespace
I'm going to start pulling apart the resolver tests into separate files, and the test helper shouldn't go into the root tint namespace.

Change-Id: Ie7d131c5b92837c6c9df05b2938cf014a0402ce2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44160
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 15:08:48 +00:00
Ben Clayton 9430cb4775 Resolver: Validate usage of break
Also remove unused fields of Resolver (block_to_info_, block_infos_). We can put them back when they're actually needed.

Fixed: tint:190
Change-Id: I1a02a24eca7fba32b8e1120abb88040138a39c6a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44051
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
2021-03-09 15:06:37 +00:00
Ben Clayton 5b36d2c612 Remove all unnecessary includes
All includes from .cc to .h are preserved, even when transitively included.

It's clear that there are far too many includes in header files, and we should be more aggressive with forward declarations. tint:532 will continue to track this work.

There are, however, plenty of includes that have accumulated over time which are no longer required directly or transitively, so this change starts with a clean slate of *required* includes.

Bug: tint:532
Change-Id: Ie1718dad565f8309fa180ef91bcf3920e76dba18
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44042
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
2021-03-09 11:11:17 +00:00
Ben Clayton 5f0ea11365 Rename TypeDeterminer to Resolver
Move out of the src root and into its own subdirectory
Rename methods to remove the 'Determine' prefix.

Fixed: tint:529
Change-Id: Idf89d647780f8a2e7495c1c9e6c402e00ad45b7c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44041
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-09 10:54:37 +00:00